-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
/
adapters.js
48 lines (37 loc) · 1.38 KB
/
adapters.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
45
46
47
48
import adapters from '../../../lib/adapters/adapters.js';
import assert from 'assert';
describe('adapters', function () {
const store = {...adapters.adapters};
beforeEach(() => {
Object.keys(adapters.adapters).forEach((name) => {
delete adapters.adapters[name];
});
Object.assign(adapters.adapters, store);
});
it('should support loading by fn handle', function () {
const adapter = () => {};
assert.strictEqual(adapters.getAdapter(adapter), adapter);
});
it('should support loading by name', function () {
const adapter = () => {};
adapters.adapters['testadapter'] = adapter;
assert.strictEqual(adapters.getAdapter('testAdapter'), adapter);
});
it('should detect adapter unavailable status', function () {
adapters.adapters['testadapter'] = null;
assert.throws(()=> adapters.getAdapter('testAdapter'), /is not available in the build/)
});
it('should detect adapter unsupported status', function () {
adapters.adapters['testadapter'] = false;
assert.throws(()=> adapters.getAdapter('testAdapter'), /is not supported by the environment/)
});
it('should pick suitable adapter from the list', function () {
const adapter = () => {};
Object.assign(adapters.adapters, {
foo: false,
bar: null,
baz: adapter
});
assert.strictEqual(adapters.getAdapter(['foo', 'bar', 'baz']), adapter);
});
});