smartexpect/test/test.ts

21 lines
664 B
TypeScript
Raw Normal View History

2022-01-21 02:33:24 +00:00
import { tap } from '@pushrocks/tapbundle';
2022-01-20 21:40:38 +00:00
import * as smartexpect from '../ts/index';
2022-01-21 02:33:24 +00:00
tap.test('sync tests', async () => {
smartexpect.expect('hello').toBeTypeofString();
smartexpect.expect(1).not.toBeTypeofString();
smartexpect.expect(true).toBeTypeofBoolean();
smartexpect.expect(true).not.toBeTypeofNumber();
});
tap.test('async tests', async (toolsArg) => {
const deferred = toolsArg.defer();
toolsArg.delayFor(4000).then(() => {
deferred.resolve('hello');
});
await smartexpect.expectAsync(deferred.promise).timeout(5000).toBeTypeofString();
await smartexpect.expectAsync(deferred.promise).not.toBeTypeofBoolean();
2022-01-20 21:40:38 +00:00
});
tap.start();