| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 { | 3 { |
| 4 const {IO} = require("io"); | 4 const {IO} = require("io"); |
| 5 const info = require("info"); | |
| 5 | 6 |
| 6 const testFileNames = { | 7 const testFileNames = { |
| 7 testData: "testData", | 8 testData: "testData", |
| 8 simpleCheck: "simpleCheck", | 9 simpleCheck: "simpleCheck", |
| 9 write: "writeCheck", | 10 write: "writeCheck", |
| 10 read: "readCheck", | 11 read: "readCheck", |
| 11 rename: "renameCheck" | 12 rename: "renameCheck" |
| 12 }; | 13 }; |
| 13 const testData = { | 14 const testData = { |
| 14 fileName: "file:" + testFileNames.testData, | 15 fileName: "file:" + testFileNames.testData, |
| 15 content: [1, 2, 3], | 16 content: [1, 2, 3], |
| 16 lastModified: Date.now() | 17 lastModified: Date.now() |
| 17 }; | 18 }; |
| 18 | 19 |
| 19 QUnit.module("IO tests", { | 20 let testEdge = info.platform == "edgehtml" ? QUnit.test : QUnit.skip; |
| 21 | |
| 22 QUnit.module("Edge filter storage", { | |
|
Sebastian Noack
2018/07/09 16:43:39
Nit: We always spell out "Microsoft Edge" to avoid
piscoi.georgiana
2018/07/09 17:09:14
Done. Thank you!
| |
| 20 beforeEach() | 23 beforeEach() |
| 21 { | 24 { |
| 22 return prePopulateStorage(); | 25 return prePopulateStorage(); |
| 23 }, | 26 }, |
| 24 afterEach() | 27 afterEach() |
| 25 { | 28 { |
| 26 return clearStorage(); | 29 return clearStorage(); |
| 27 } | 30 } |
| 28 }); | 31 }); |
| 29 | 32 |
| 30 test("statFile", assert => | 33 testEdge("statFile", assert => |
| 31 { | 34 { |
| 32 const noFileMsg = "returns correct value if file doesn't exist"; | 35 const noFileMsg = "returns correct value if file doesn't exist"; |
| 33 const fileExistsMsg = "returns correct value if file exists"; | 36 const fileExistsMsg = "returns correct value if file exists"; |
| 34 | 37 |
| 35 ok(IO.statFile(testFileNames.simpleCheck) instanceof Promise, | 38 ok(IO.statFile(testFileNames.simpleCheck) instanceof Promise, |
| 36 "returns a promise"); | 39 "returns a promise"); |
| 37 | 40 |
| 38 asyncReadHelper( | 41 asyncReadHelper( |
| 39 IO.statFile, | 42 IO.statFile, |
| 40 testFileNames.testData, | 43 testFileNames.testData, |
| 41 {exists: true, lastModified: testData.lastModified}, | 44 {exists: true, lastModified: testData.lastModified}, |
| 42 fileExistsMsg, | 45 fileExistsMsg, |
| 43 assert); | 46 assert); |
| 44 | 47 |
| 45 asyncReadHelper( | 48 asyncReadHelper( |
| 46 IO.statFile, | 49 IO.statFile, |
| 47 testFileNames.simpleCheck, | 50 testFileNames.simpleCheck, |
| 48 {exists: false}, | 51 {exists: false}, |
| 49 noFileMsg, | 52 noFileMsg, |
| 50 assert); | 53 assert); |
| 51 }); | 54 }); |
| 52 | 55 |
| 53 test("writeToFile", assert => | 56 testEdge("writeToFile", assert => |
| 54 { | 57 { |
| 55 ok(IO.writeToFile(testFileNames.simpleCheck, ["test"]) instanceof Promise, | 58 ok(IO.writeToFile(testFileNames.simpleCheck, ["test"]) instanceof Promise, |
| 56 "returns a promise"); | 59 "returns a promise"); |
| 57 | 60 |
| 58 writesCorrectValue(assert); | 61 writesCorrectValue(assert); |
| 59 }); | 62 }); |
| 60 | 63 |
| 61 function writesCorrectValue(assert) | 64 function writesCorrectValue(assert) |
| 62 { | 65 { |
| 63 const writeCheck = { | 66 const writeCheck = { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 77 "data is written in the correct format"); | 80 "data is written in the correct format"); |
| 78 | 81 |
| 79 deepEqual( | 82 deepEqual( |
| 80 writeCheck.content, | 83 writeCheck.content, |
| 81 result.content, | 84 result.content, |
| 82 "data has the correct content"); | 85 "data has the correct content"); |
| 83 done(); | 86 done(); |
| 84 }); | 87 }); |
| 85 } | 88 } |
| 86 | 89 |
| 87 test("readFromFile", assert => | 90 testEdge("readFromFile", assert => |
| 88 { | 91 { |
| 89 const noFileMsg = "returns correct value if file doesn't exist"; | 92 const noFileMsg = "returns correct value if file doesn't exist"; |
| 90 | 93 |
| 91 ok(IO.readFromFile(testFileNames.simpleCheck) instanceof Promise, | 94 ok(IO.readFromFile(testFileNames.simpleCheck) instanceof Promise, |
| 92 "returns a promise"); | 95 "returns a promise"); |
| 93 | 96 |
| 94 asyncReadHelper( | 97 asyncReadHelper( |
| 95 IO.readFromFile, | 98 IO.readFromFile, |
| 96 testFileNames.read, | 99 testFileNames.read, |
| 97 {type: "NoSuchFile"}, | 100 {type: "NoSuchFile"}, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 111 .then(() => | 114 .then(() => |
| 112 { | 115 { |
| 113 deepEqual( | 116 deepEqual( |
| 114 called, | 117 called, |
| 115 testData.content, | 118 testData.content, |
| 116 "calls listeners with the correct values"); | 119 "calls listeners with the correct values"); |
| 117 done(); | 120 done(); |
| 118 }); | 121 }); |
| 119 } | 122 } |
| 120 | 123 |
| 121 test("renameFile", assert => | 124 testEdge("renameFile", assert => |
| 122 { | 125 { |
| 123 ok(IO.renameFile(testFileNames.simpleCheck) instanceof Promise, | 126 ok(IO.renameFile(testFileNames.simpleCheck) instanceof Promise, |
| 124 "returns a promise"); | 127 "returns a promise"); |
| 125 | 128 |
| 126 checkRename(assert); | 129 checkRename(assert); |
| 127 }); | 130 }); |
| 128 | 131 |
| 129 function checkRename(assert) | 132 function checkRename(assert) |
| 130 { | 133 { |
| 131 let done = assert.async(); | 134 let done = assert.async(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 221 |
| 219 store.delete("file:" + fileName).onsuccess = resolveFile; | 222 store.delete("file:" + fileName).onsuccess = resolveFile; |
| 220 })); | 223 })); |
| 221 | 224 |
| 222 Promise.all(files).then(resolve); | 225 Promise.all(files).then(resolve); |
| 223 }; | 226 }; |
| 224 }); | 227 }); |
| 225 } | 228 } |
| 226 } | 229 } |
| 227 | 230 |
| OLD | NEW |