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

3
test/yesNo/yesNo.js Normal file
View File

@ -0,0 +1,3 @@
const yesNo = (val, def = false) =>
/^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def;
module.exports = yesNo;

46
test/yesNo/yesNo.test.js Normal file
View File

@ -0,0 +1,46 @@
const expect = require('expect');
const yesNo = require('./yesNo.js');
test('yesNo is a Function', () => {
expect(yesNo).toBeInstanceOf(Function);
});
test('yesNo(Y) returns true', () => {
expect(yesNo('Y')).toBeTruthy();
});
test('yesNo(yes) returns true', () => {
expect(yesNo('yes')).toBeTruthy();
});
test('yesNo(foo, true) returns true', () => {
expect(yesNo('foo', true)).toBeTruthy();
});
test('yesNo(No) returns false', () => {
expect(yesNo('No')).toBeFalsy();
});
test('yesNo() returns false', () => {
expect(yesNo()).toBeFalsy();
});
test('yesNo(null) returns false', () => {
expect(yesNo(null)).toBeFalsy();
});
test('yesNo(undefined) returns false', () => {
expect(yesNo(undefined)).toBeFalsy();
});
test('yesNo([123, null]) returns false', () => {
expect(yesNo([123, null])).toBeFalsy();
});
test('yesNo([Yes, No]) returns false', () => {
expect(yesNo(['Yes', 'No'])).toBeFalsy();
});
test('yesNo({ 2: Yes }) returns false', () => {
expect(yesNo({ 2: 'Yes' })).toBeFalsy();
});
test('yesNo([Yes, No], true) returns true', () => {
expect(yesNo(['Yes', 'No'], true)).toBeTruthy();
});
test('yesNo({ 2: Yes }, true) returns true', () => {
expect(yesNo({ 2: 'Yes' }, true)).toBeTruthy();
});