MCPcopy Create free account
hub / github.com/itinance/react-native-fs / testWriteAndReadFile

Function testWriteAndReadFile

IntegrationTests/FSTest.js:42–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42function testWriteAndReadFile() {
43 var path = RNFS.DocumentDirectoryPath + '/test.txt';
44
45 var text = 'Lorem ipsum dolor sit amet';
46 var readText;
47
48 RNFS.writeFile(path, text)
49 .then((success) => {
50 updateMessage('FILE WRITTEN!');
51 return RNFS.readFile(path);
52 })
53 .then((contents) => {
54 updateMessage('FILE READ! Contents:');
55 readText = contents;
56 expectEqual(text, readText, 'testWriteAndReadFile');
57 updateMessage('readFile correctly returned' + readText);
58 })
59 .finally(() => {
60 runTestCase('testCreateAndDeleteFile', testCreateAndDeleteFile);
61 })
62 .done();//promise done needed to throw exception so that in case test fails,error is propagated
63}
64
65
66

Callers 1

componentDidMountFunction · 0.85

Calls 4

expectEqualFunction · 0.85
runTestCaseFunction · 0.85
writeFileMethod · 0.45
readFileMethod · 0.45

Tested by

no test coverage detected