Files
30-seconds-of-code/test/words/words.test.js
Angelos Chalaris 4f7da1be9b Test migration to jest by hand
Apparently using regular expressions is way easier.
2018-06-18 15:15:56 +03:00

22 lines
958 B
JavaScript

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');