This repository was archived by the owner on Aug 28, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathProviderStore.ts
81 lines (60 loc) · 1.79 KB
/
ProviderStore.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import unknownTest, { TestInterface } from 'ava';
import { createClient } from './lib/SettingsClient';
import {
KlasaClient,
Provider,
ProviderStore
} from '../src';
const ava = unknownTest as TestInterface<{
client: KlasaClient
}>;
ava.beforeEach(async (test): Promise<void> => {
test.context = {
client: createClient()
};
});
ava('ProviderStore Properties', (test): void => {
test.plan(6);
const { providers } = test.context.client;
// Test the store's properties
test.true(providers instanceof ProviderStore);
test.is(providers.client, test.context.client);
test.is(providers.Holds, Provider);
test.is(providers.name, 'providers');
// Mock provider from tests
test.is(providers.size, 1);
test.true(providers.has('json'));
});
ava('ProviderStore#default', (test): void => {
test.plan(2);
const { providers } = test.context.client;
test.context.client.options.providers.default = 'json';
test.is(providers.default, providers.get('json'));
providers.clear();
test.is(providers.default, null);
});
ava('ProviderStore#clear', (test): void => {
test.plan(2);
const { providers } = test.context.client;
test.is(providers.size, 1);
providers.clear();
test.is(providers.size, 0);
});
ava('ProviderStore#delete (From Name)', (test): void => {
test.plan(2);
const { providers } = test.context.client;
test.true(providers.remove('json'));
test.is(providers.size, 0);
});
ava('ProviderStore#delete (From Instance)', (test): void => {
test.plan(2);
const { providers } = test.context.client;
test.true(providers.remove(providers.get('json') as Provider));
test.is(providers.size, 0);
});
ava('ProviderStore#delete (Invalid)', (test): void => {
test.plan(2);
const { providers } = test.context.client;
test.false(providers.remove('DoesNotExist'));
test.is(providers.size, 1);
});