Skip to content

Commit

Permalink
Add tests for isLoadable
Browse files Browse the repository at this point in the history
  • Loading branch information
fboeller committed Mar 7, 2021
1 parent ba2531a commit ba74be7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions projects/ngx-loadable/src/lib/loadable.functions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { errored, idle, loaded, loading } from './loadable.constructors';
import { isLoadable } from './loadable.functions';
import { Loadable } from './loadable.type';

describe('isLoadable', () => {
it.each([[idle], [loading], [loaded('value')], [errored('error')]])(
'returns true for %s',
(loadable: Loadable<unknown>) => {
expect(isLoadable(loadable)).toBeTruthy();
}
);

it.each([
[[]],
[{}],
[undefined],
[null],
[0],
[''],
['value'],
[{ type: undefined }],
[{ type: null }],
[{ type: 'load' }],
[{ value: 'value' }],
[{ error: 'error' }],
])('returns false for %s', (object: unknown) => {
expect(isLoadable(object)).toBeFalsy();
});
});

0 comments on commit ba74be7

Please sign in to comment.