-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_test.js
44 lines (36 loc) · 1.05 KB
/
mod_test.js
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
import { assert, assertEquals, assertThrows } from './dev_deps.js'
import elasticsearchAdapterFactory from './mod.js'
Deno.test('validate adapter', () => {
const adapter = elasticsearchAdapterFactory({})
assert(adapter)
})
Deno.test('validate load()', () => {
const config = { foo: 'bar' }
const adapter = elasticsearchAdapterFactory(config)
const loadedConfig = adapter.load({ fizz: 'buzz' })
assertEquals(loadedConfig.foo, config.foo)
assertEquals(loadedConfig.fizz, 'buzz')
})
Deno.test('validate link()', () => {
const config = {
username: 'foo',
password: 'bar',
url: 'http://localhost:9200',
}
const adapter = elasticsearchAdapterFactory(config)
assert(adapter.link(config)())
})
Deno.test('validate link() - no url', () => {
const config = {
username: 'foo',
password: 'bar',
// deno-lint-ignore camelcase
no_url: 'http://localhost:9200',
}
const adapter = elasticsearchAdapterFactory(config)
assertThrows(
() => adapter.link(config)(),
Error,
'Config URL is required elastic search',
)
})