2022-01-21 02:33:24 +00:00
|
|
|
import { tap } from '@pushrocks/tapbundle';
|
2022-07-24 10:45:29 +00:00
|
|
|
import * as smartexpect from '../ts/index.js';
|
2022-01-20 21:40:38 +00:00
|
|
|
|
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
|
|
|
});
|
|
|
|
|
2022-01-21 16:37:30 +00:00
|
|
|
tap.test('should check equality', async () => {
|
|
|
|
smartexpect.expect('hithere').toEqual('hithere');
|
|
|
|
smartexpect.expect('hithere').not.toEqual('hithere2');
|
2022-07-24 10:45:29 +00:00
|
|
|
});
|
2022-01-21 16:37:30 +00:00
|
|
|
|
2023-06-22 09:57:29 +00:00
|
|
|
tap.test('should check for regexp matching', async () => {
|
|
|
|
smartexpect.expect('hithere').toMatch(/hi/);
|
|
|
|
smartexpect.expect('hithere').not.toMatch(/ho/);
|
2023-07-10 00:49:04 +00:00
|
|
|
});
|
2023-06-22 09:57:29 +00:00
|
|
|
|
2022-02-02 01:45:45 +00:00
|
|
|
tap.test('should correctly state property presence', async () => {
|
|
|
|
const testObject = {
|
2022-07-24 10:45:29 +00:00
|
|
|
aprop: 'hello',
|
2022-02-02 01:45:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
smartexpect.expect(testObject).toHaveProperty('aprop');
|
|
|
|
smartexpect.expect(testObject).not.toHaveProperty('aprop2');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should be greater than', async () => {
|
|
|
|
smartexpect.expect(4).toBeGreaterThan(3);
|
|
|
|
smartexpect.expect(4).toBeLessThan(5);
|
2022-07-24 10:45:29 +00:00
|
|
|
});
|
2022-02-02 01:45:45 +00:00
|
|
|
|
2022-02-02 07:02:26 +00:00
|
|
|
tap.test('should correctly determine toContain', async () => {
|
|
|
|
const hello = {
|
2022-07-24 10:45:29 +00:00
|
|
|
socool: 'yes',
|
2022-02-02 07:02:26 +00:00
|
|
|
};
|
|
|
|
const testArray = [hello];
|
|
|
|
smartexpect.expect(testArray).toContain(hello);
|
2022-07-24 10:45:29 +00:00
|
|
|
});
|
2022-02-02 07:02:26 +00:00
|
|
|
|
2022-01-20 21:40:38 +00:00
|
|
|
tap.start();
|