Skip to content

Commit 70f2fc1

Browse files
committed
test: Add options and init tests to adapter tests
1 parent 4057a73 commit 70f2fc1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

adapter-tests/unit-tests.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,43 @@ module.exports = function testAdapter(options) {
4343
expect(adapter.put('/a-key', {}).constructor.name).toEqual("Promise")
4444
})
4545

46+
if (typeof adapter.options !== "undefined") {
47+
test('options should be an array of args options', () => {
48+
expect(Array.isArray(adapter.options)).toBe(true)
49+
if (adapter.options.length >= 0) {
50+
let counter = 0
51+
adapter.options.forEach(option => {
52+
expect(option.name).toBeDefined()
53+
expect(option.description).toBeDefined()
54+
counter++
55+
})
56+
57+
// if the forEach somehow breaks the test should break
58+
expect(counter).toBe(adapter.options.length)
59+
}
60+
})
61+
62+
test('init should be a defined when options is defined', () => {
63+
expect(typeof adapter.init).not.toBe("undefined");
64+
})
65+
} else {
66+
test.skip('options should be an array of args options', () => {})
67+
test.skip('init should be a defined when options is defined', () => {})
68+
}
69+
70+
if (typeof adapter.init !== "undefined") {
71+
test('init should be a function', () => {
72+
expect(typeof adapter.init).toBe("function");
73+
})
74+
75+
test('call init should not throw', () => {
76+
adapter.init(options.initOptions || {})
77+
})
78+
} else {
79+
test.skip('init should be a function', () => {})
80+
test.skip('call init should not throw', () => {})
81+
}
82+
4683
it('should save and read', async () => {
4784
await adapter.put('/a-key', { views: [{ time: 1490623474639 }] });
4885

@@ -167,6 +204,9 @@ module.exports = function testAdapter(options) {
167204
value: { views: [{ time: 1490623474639 }] },
168205
});
169206
});
207+
} else {
208+
it.skip('should allow subscription with observables', () => {})
209+
it.skip('should allow multiple subscription with observables and handle unsubscribption', () => {})
170210
}
171211
});
172212
};

0 commit comments

Comments
 (0)