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 5df7098fac
commit a78f5db260
894 changed files with 5917 additions and 3607 deletions

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

@ -0,0 +1,2 @@
const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
module.exports = words;

21
test/words/words.test.js Normal file
View File

@ -0,0 +1,21 @@
const expect = require('expect');
const words = require('./words.js');
test('words is a Function', () => {
expect(words).toBeInstanceOf(Function);
});
t.deepEqual(words('I love javaScript!!'), ["I", "love", "javaScript"], "words('I love javaScript!!') returns [I, love, javaScript]");
t.deepEqual(words('python, javaScript & coffee'), ["python", "javaScript", "coffee"], "words('python, javaScript & coffee') returns [python, javaScript, coffee]");
test('words(I love javaScript!!) returns an array', () => {
expect(Array.isArray(words('I love javaScript!!'))).toBeTruthy();
});
t.throws(() => words(), 'words() throws a error');
t.throws(() => words(null), 'words(null) throws a error');
t.throws(() => words(undefined), 'words(undefined) throws a error');
t.throws(() => words({}), 'words({}) throws a error');
t.throws(() => words([]), 'words([]) throws a error');
t.throws(() => words(1234), 'words(1234) throws a error');