summaryrefslogtreecommitdiff
path: root/tests/papo.js
blob: 2a4f2e6f313b750420f03c4d070b089c5c64dd8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {
	configureStorage,
} from "../src/content/papo.exported.js";



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_configureStorage,
];