Test migration to jest by hand

Apparently using regular expressions is way easier.
This commit is contained in:
Angelos Chalaris
2018-06-18 15:15:56 +03:00
parent 977949ca61
commit 4f7da1be9b
894 changed files with 5917 additions and 3607 deletions

2
test/head/head.js Normal file
View File

@ -0,0 +1,2 @@
const head = arr => arr[0];
module.exports = head;

24
test/head/head.test.js Normal file
View File

@ -0,0 +1,24 @@
const expect = require('expect');
const head = require('./head.js');
test('head is a Function', () => {
expect(head).toBeInstanceOf(Function);
});
test('head({ a: 1234}) returns undefined', () => {
expect(head({ a: 1234}) === undefined).toBeTruthy();
});
t.equal(head([1, 2, 3]), 1, "head([1, 2, 3]) returns 1");
t.equal(head({ 0: false}), false, 'head({ 0: false}) returns false');
t.equal(head('String'), 'S', 'head(String) returns S');
t.throws(() => head(null), 'head(null) throws an Error');
t.throws(() => head(undefined), 'head(undefined) throws an Error');
t.throws(() => head(), 'head() throws an Error');
let start = new Date().getTime();
head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]);
let end = new Date().getTime();
test('head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => {
expect((end - start) < 2000).toBeTruthy();
});