-
Notifications
You must be signed in to change notification settings - Fork 5
/
setupTest.cjs
54 lines (51 loc) · 1.18 KB
/
setupTest.cjs
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
import { vi } from 'vitest';
vi.mock('$app/stores', async () => {
const { readable, writable } = await import('svelte/store');
/**
* @type {import('$app/stores').getStores}
*/
const getStores = () => ({
navigating: readable(null),
page: readable({ url: new URL('http://localhost'), params: {} }),
session: writable(null),
updated: readable(false)
});
/** @type {typeof import('$app/stores').page} */
const page = {
subscribe(fn) {
return getStores().page.subscribe(fn);
}
};
/** @type {typeof import('$app/stores').navigating} */
const navigating = {
subscribe(fn) {
return getStores().navigating.subscribe(fn);
}
};
/** @type {typeof import('$app/stores').session} */
const session = {
subscribe(fn) {
return getStores().session.subscribe(fn);
}
};
/** @type {typeof import('$app/stores').updated} */
const updated = {
subscribe(fn) {
return getStores().updated.subscribe(fn);
}
};
return {
getStores,
navigating,
page,
session,
updated
};
});
vi.mock('$app/environment', async () => {
return {
browser: true
};
});
window.alert = console.error;
prompt = () => true;