Files
30-seconds-of-code/test/yesNo.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

42 lines
1.2 KiB
JavaScript

const {yesNo} = require('./_30s.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();
});