-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigcache.test.mjs
36 lines (30 loc) · 1.53 KB
/
configcache.test.mjs
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
import * as configcache from './configcache.mjs';
import {default as admin} from 'firebase-admin';
const cacheBase = admin.initializeApp({
apiKey: "AIzaSyBquSsEgQnG_rHyasUA95xHN5INnvnh3gc",
authDomain: "endpointserviceusers.firebaseapp.com",
projectId: "endpointserviceusers",
appId: "1:283622646315:web:baa488124636283783006e"
}, 'users');
configcache.setCacheFirebase(cacheBase);
test('configcache getNotebook reads from setNotebook', async () => {
await configcache.setNotebook('ryow;foo', {"bar": "baz"});
expect(await configcache.getNotebook('ryow;foo')).toEqual({
"bar": "baz"
})
});
test('configcache getDynamic for /observablehq.com/d/6eda90668ae03044;info', async () => {
const cache = await configcache.getDynamic('/observablehq.com/d/6eda90668ae03044;info');
expect(cache.secrets).toEqual(['tomlarkworthy_example_secret']);
});
test('configcache get for /observablehq.com/d/6eda90668ae03044;info merges secrets with setNotebook', async () => {
await configcache.setNotebook('/observablehq.com/d/6eda90668ae03044;info', {"secrets": ['foo']});
expect(await configcache.getNotebook('/observablehq.com/d/6eda90668ae03044;info')).toEqual(
{"secrets": ['foo']})
const cache = await configcache.get('/observablehq.com/d/6eda90668ae03044;info');
expect(cache.secrets).toEqual(['tomlarkworthy_example_secret', 'foo']);
});
test('configcache get of unknown resolves to undefined', async () => {
const cache = await configcache.get('blah', 'info');
expect(cache).toBeUndefined();
});