Skip to content

Commit 5b6fb0a

Browse files
committed
Add adapter tests that checks that promises are returned
Even tho not all adapters are async they should resolve promises to keep the api consistent.
1 parent 2add293 commit 5b6fb0a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

adapter-tests/unit-tests.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ module.exports = function testAdapter(options) {
2323
});
2424
}
2525

26+
test('get() should return a promise', () => {
27+
expect(adapter.get('/a-key').constructor.name).toEqual("Promise")
28+
})
29+
30+
test('getAll() should return a promise', () => {
31+
expect(adapter.getAll({ pathname: '/' }).constructor.name).toEqual("Promise")
32+
})
33+
34+
test('has() should return a promise', () => {
35+
expect(adapter.has('/a-key').constructor.name).toEqual("Promise")
36+
})
37+
38+
test('keys() should return a promise', () => {
39+
expect(adapter.keys().constructor.name).toEqual("Promise")
40+
})
41+
42+
test('put() should return a promise', () => {
43+
expect(adapter.put('/a-key', {}).constructor.name).toEqual("Promise")
44+
})
45+
2646
it('should save and read', async () => {
2747
await adapter.put('/a-key', { views: [{ time: 1490623474639 }] });
2848

0 commit comments

Comments
 (0)