-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeolite2_provider.spec.ts
54 lines (49 loc) · 1.51 KB
/
geolite2_provider.spec.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
import { test } from '@japa/runner'
import { IgnitorFactory } from '@adonisjs/core/factories'
import { defineConfig } from '../src/define_config.js'
import GeoLite2Manager from '../src/manager.js'
const BASE_URL = new URL('./tmp/', import.meta.url)
test.group('GeoLite2 Provider', () => {
test('register geolite2 provider', async ({ assert }) => {
const ignitor = new IgnitorFactory()
.withCoreConfig()
.withCoreProviders()
.merge({
config: {
geolite2: defineConfig({
downloadDirectory: './tmp',
cache: 6000,
}),
},
rcFileContents: {
providers: [() => import('../providers/geolite2_provider.js')],
},
})
.create(BASE_URL)
const app = ignitor.createApp('web')
await app.init()
await app.boot()
assert.instanceOf(await app.container.make('geolite2'), GeoLite2Manager)
await app.terminate()
})
test('throw error when config is invalid', async () => {
const ignitor = new IgnitorFactory()
.withCoreConfig()
.withCoreProviders()
.merge({
config: {
geolite2: {},
},
rcFileContents: {
providers: [() => import('../providers/geolite2_provider.js')],
},
})
.create(BASE_URL)
const app = ignitor.createApp('web')
await app.init()
await app.boot()
await app.container.make('geolite2')
}).throws(
'Invalid default export from "config/geolite2.ts" file. Make sure to use defineConfig method'
)
})