()
| 65 | |
| 66 | |
| 67 | function 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 |
nothing calls this directly
no test coverage detected