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

View File

@ -1,23 +1,37 @@
const expect = require('expect');
const average = require('./average.js');
test('Testing average', () => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
expect(typeof average === 'function').toBeTruthy();
test('average is a Function', () => {
expect(average).toBeInstanceOf(Function);
});
test('average(true) returns 0', () => {
expect(average(true) === 1).toBeTruthy();
});
test('average(false) returns 1', () => {
expect(average(false) === 0).toBeTruthy();
expect(average(9, 1)).toBe(5);
expect(average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631)).toBe(32163.909090909092);
expect(average(1, 2, 3)).toBe(2);
expect(average(null)).toBe(0);
});
t.equal(average(9, 1), 5, 'average(9, 1) returns 5');
t.equal(average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631), 32163.909090909092, 'average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 ');
t.equal(average(1, 2, 3), 2, 'average(1, 2, 3) returns 2');
t.equal(average(null), 0, 'average(null) returns 0');
test('average(1, 2, 3) returns NaN', () => {
expect(isNaN(average(undefined))).toBeTruthy();
});
test('average(String) returns NaN', () => {
expect(isNaN(average('String'))).toBeTruthy();
});
test('average({ a: 123}) returns NaN', () => {
expect(isNaN(average({ a: 123}))).toBeTruthy();
});
test('average([undefined, 0, string]) returns NaN', () => {
expect(isNaN(average([undefined, 0, 'string']))).toBeTruthy();
});
let start = new Date().getTime();
average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631);
let end = new Date().getTime();
let end = new Date().getTime();
test('average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run', () => {
expect((end - start) < 2000).toBeTruthy();
});
});