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,21 +1,24 @@
const expect = require('expect');
const chunk = require('./chunk.js');
test('Testing chunk', () => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
expect(typeof chunk === 'function').toBeTruthy();
expect(chunk([1, 2, 3, 4, 5], 2)).toEqual([[1,2],[3,4],[5]]);
expect(chunk([])).toEqual([]);
expect(chunk(123)).toEqual([]);
expect(chunk({ a: 123})).toEqual([]);
expect(chunk('string', 2)).toEqual([ 'st', 'ri', 'ng' ]);
expect(() => chunk()).toThrow();
expect(() => chunk(undefined)).toThrow();
expect(() => chunk(null)).toThrow();
test('chunk is a Function', () => {
expect(chunk).toBeInstanceOf(Function);
});
t.deepEqual(chunk([1, 2, 3, 4, 5], 2), [[1,2],[3,4],[5]], "chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] ");
t.deepEqual(chunk([]), [], 'chunk([]) returns []');
t.deepEqual(chunk(123), [], 'chunk(123) returns []');
t.deepEqual(chunk({ a: 123}), [], 'chunk({ a: 123}) returns []');
t.deepEqual(chunk('string', 2), [ 'st', 'ri', 'ng' ], 'chunk(string, 2) returns [ st, ri, ng ]');
t.throws(() => chunk(), 'chunk() throws an error');
t.throws(() => chunk(undefined), 'chunk(undefined) throws an error');
t.throws(() => chunk(null), 'chunk(null) throws an error');
let start = new Date().getTime();
chunk('This is a string', 2);
let end = new Date().getTime();
test('chunk(This is a string, 2) takes less than 2s to run', () => {
expect((end - start) < 2000).toBeTruthy();
});