Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions react-native-file-selector/demo/file_selectorDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { Button, SafeAreaView } from 'react-native';
import FileSelector from 'react-native-file-selector';
import { Tester, TestSuite, TestCase } from '@rnoh/testerino';

const App=()=>{
return (<SafeAreaView>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify onDone"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({onDone:(path)=>{setState(true); alert('path = ' + path);}});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify onCancel"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({onCancel:()=>{setState(true); alert('cancelled');}});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify filter"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({filter:".mp4,.jpeg", onDone:(path)=>{setState(true);}});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify path"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({path: '/storage/Users/currentUser/Documents',
onDone: (path)=>{setState(true);}
});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
</SafeAreaView>);
};

export default App;
104 changes: 104 additions & 0 deletions react-native-file-selector/test/file_selectorTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { Button, SafeAreaView } from 'react-native';
import FileSelector from 'react-native-file-selector';
import { Tester, TestSuite, TestCase } from '@rnoh/testerino';

const App=()=>{
return (<SafeAreaView>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify onDone"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({onDone:(path)=>{setState(true); alert('path = ' + path);}});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify onCancel"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({onCancel:()=>{setState(true); alert('cancelled');}});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify filter"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({filter:".mp4,.jpeg", onDone:(path)=>{setState(true);}});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
<Tester>
<TestSuite name="test file selector">
<TestCase itShould="specify path"
assert={({expect, state})=>{
expect(state).to.be.true
}}
initialState={false}
tags={['C_API']}
arrange={
({setState})=>{
return (<Button title="click"
onPress={
()=>{
FileSelector.Show({path: '/storage/Users/currentUser/Documents',
onDone: (path)=>{setState(true);}
});
}
}
/>)
}
}
>
</TestCase>
</TestSuite>
</Tester>
</SafeAreaView>);
};

export default App;