Skip to content

Commit ba74be7

Browse files
committed
Add tests for isLoadable
1 parent ba2531a commit ba74be7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { errored, idle, loaded, loading } from './loadable.constructors';
2+
import { isLoadable } from './loadable.functions';
3+
import { Loadable } from './loadable.type';
4+
5+
describe('isLoadable', () => {
6+
it.each([[idle], [loading], [loaded('value')], [errored('error')]])(
7+
'returns true for %s',
8+
(loadable: Loadable<unknown>) => {
9+
expect(isLoadable(loadable)).toBeTruthy();
10+
}
11+
);
12+
13+
it.each([
14+
[[]],
15+
[{}],
16+
[undefined],
17+
[null],
18+
[0],
19+
[''],
20+
['value'],
21+
[{ type: undefined }],
22+
[{ type: null }],
23+
[{ type: 'load' }],
24+
[{ value: 'value' }],
25+
[{ error: 'error' }],
26+
])('returns false for %s', (object: unknown) => {
27+
expect(isLoadable(object)).toBeFalsy();
28+
});
29+
});

0 commit comments

Comments
 (0)