diff options
Diffstat (limited to 'tests/papo.js')
-rw-r--r-- | tests/papo.js | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/tests/papo.js b/tests/papo.js index 188ca67..2a4f2e6 100644 --- a/tests/papo.js +++ b/tests/papo.js @@ -1,19 +1,55 @@ import { - f1, + configureStorage, } from "../src/content/papo.exported.js"; -const test_f1 = async t => { - t.start("f1()"); - t.test("addition", () => { - t.assert.equal(f1(1), 2); - // t.assert.equal(f1(1), 3); +const test_configureStorage = async t => { + t.start("configureStorage()"); + + const contents = []; + const err = x => contents.push(x); + + const navigator = { + storage: { + persist: () => Promise.resolve(true), + }, + }; + + const env = { + err, + navigator, + }; + + + return + t.test("noop when successful", async () => { + console.log(1); + await configureStorage(env); + console.log(2); + t.assert.deepEqual(contents, []); + }); + + t.test("noop if not available", async () => { + delete env.navigator.storage.persist; + console.log(3); + await configureStorage(env); + console.log(4); + t.assert.deepEqual(contents, [ + "Persistent storage is not supported", + ]); + + delete env.navigator.storage; + await configureStorage(env); + t.assert.deepEqual(contents, [ + "Persistent storage is not supported", + "Persistent storage is not supported", + ]); }); }; export const allTests = [ - test_f1, + test_configureStorage, ]; |