generated from hyper63/adapter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.test.ts
61 lines (54 loc) · 1.56 KB
/
mod.test.ts
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
56
57
58
59
60
61
import { assert, assertRejects, dataPort, pluginFactory } from './dev_deps.ts'
import { AtlasDataClient } from './clients/atlas-data.ts'
import factory from './mod.ts'
import { MetaDb } from './meta.ts'
Deno.test('mod', async (t) => {
const happy = {
url: 'https://data.mongodb-api.com/app/foo/endpoint/data/v1',
options: {
atlas: {
dataSource: 'foo',
auth: {
apiKey: 'secret',
},
},
},
}
await t.step('should implement the factory schema', () => {
assert(pluginFactory(factory(happy)))
})
await t.step('load', async (t) => {
await t.step(
'should construct an AtlasData client and MetaDb client',
async () => {
const { client, meta } = await factory(happy).load()
assert(client instanceof AtlasDataClient)
assert(meta instanceof MetaDb)
},
)
await t.step('should throw if the provided url is not valid', async () => {
await assertRejects(() =>
factory({
url: 'foobar://user:[email protected]/test',
}).load()
)
})
await t.step('should throw if no atlas options are provided', async () => {
await assertRejects(() =>
factory({
...happy,
options: {
atlas: undefined,
},
}).load()
)
})
})
await t.step('link', async (t) => {
await t.step('should return a data adapter', async () => {
const plugin = factory(happy)
const adapter = plugin.link(await plugin.load())({})
assert(dataPort(adapter))
})
})
})