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

Function testCreateAndDeleteFile

IntegrationTests/FSTest.js:67–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66
67function testCreateAndDeleteFile() {
68 var path = RNFS.DocumentDirectoryPath + '/test.txt';
69 var text = 'Lorem ipsum dolor sit amet';
70 var readText;
71
72 RNFS.writeFile(path, text)
73 .then((success) => {
74 updateMessage('FILE CREATED!');
75 return RNFS.unlink(path);
76 })
77 .spread((success, path) => {
78 updateMessage('FILE DELETED!' + success + ',' + path);
79 return RNFS.stat(path);
80 })
81 .then((statResult) => {
82 updateMessage('*****' + statResult);
83 if (statResult.isFile()) {
84 updateMessage('FILE STILL EXISTS');
85 }
86 })
87 .catch((err) => {
88 updateMessage('catch' + err);
89 expectTrue(true,'File is deleted');
90 })
91 .finally(() => {
92 done(); //testrunners done
93 })
94 .done(); //promise done needed to throw exception so that in case test fails,error is propagated
95}
96
97
98

Callers

nothing calls this directly

Calls 4

expectTrueFunction · 0.85
writeFileMethod · 0.45
unlinkMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected