Files
30-seconds-of-code/test/words.test.js
Christian C. Salvadó 83a6a6ea32 [ENHANCEMENT] Properly configure eslint to work with jest (#988)
* chore: make aware eslint that we use jest

By setting up the jest environment, we no longer need to declare the
'test' global in the configuration.

* chore: don't need to import expect, it's a jest environment global

* chore: don't need to import expect when creating undefined test
2019-06-18 08:34:45 +03:00

45 lines
1.1 KiB
JavaScript

const {words} = require('./_30s.js');
test('words is a Function', () => {
expect(words).toBeInstanceOf(Function);
});
test("words('I love javaScript!!') returns [I, love, javaScript]", () => {
expect(words('I love javaScript!!')).toEqual(['I', 'love', 'javaScript']);
});
test("words('python, javaScript & coffee') returns [python, javaScript, coffee]", () => {
expect(words('python, javaScript & coffee')).toEqual(['python', 'javaScript', 'coffee']);
});
test('words(I love javaScript!!) returns an array', () => {
expect(Array.isArray(words('I love javaScript!!'))).toBeTruthy();
});
test('words() throws an error', () => {
expect(() => {
words();
}).toThrow();
});
test('words(null) throws an error', () => {
expect(() => {
words(null);
}).toThrow();
});
test('words(undefined) throws an error', () => {
expect(() => {
words(undefined);
}).toThrow();
});
test('words({}) throws an error', () => {
expect(() => {
words({});
}).toThrow();
});
test('words([]) throws an error', () => {
expect(() => {
words([]);
}).toThrow();
});
test('words(1234) throws an error', () => {
expect(() => {
words(1234);
}).toThrow();
});