-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
11,656 additions
and
7,806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
["@babel/preset-env", { | ||
"targets": { | ||
"browsers": ["last 2 versions", "safari >= 7"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"extends": "airbnb", | ||
"parser": "babel-eslint" | ||
"parser": "babel-eslint", | ||
"env": { | ||
"jest": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,6 @@ settings.json | |
|
||
lib | ||
dist | ||
|
||
# stryker | ||
reports/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
import test from 'tape'; | ||
import FN from './fn'; | ||
|
||
test('FN should be a function', (assert) => { | ||
assert.equal(typeof FN, 'function'); | ||
assert.end(); | ||
}); | ||
describe('FN', () => { | ||
it('FN should be a function', () => { | ||
expect(typeof FN).toEqual('function'); | ||
}); | ||
|
||
test('FN test api: calling equals', (assert) => { | ||
const left = 'hello'; | ||
const right = 'hello'; | ||
const actual = FN('equals')(left, right); | ||
const expected = true; | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
it('FN test api: calling equals', () => { | ||
const left = 'hello'; | ||
const right = 'hello'; | ||
const actual = FN('equals')(left, right); | ||
const expected = true; | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('FN test api: calling !equals', (assert) => { | ||
const left = 'hello'; | ||
const right = 'hello'; | ||
const actual = FN('!equals')(left, right); | ||
const expected = false; | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
it('FN test api: calling !equals', () => { | ||
const left = 'hello'; | ||
const right = 'hello'; | ||
const actual = FN('!equals')(left, right); | ||
const expected = false; | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('FN should accept a custom eval function', (assert) => { | ||
const custom = { | ||
equalsSquirm: left => left === 'squirm', | ||
}; | ||
let left = 'squirm'; | ||
let actual = FN('equalsSquirm', custom)(left); | ||
let expected = true; | ||
assert.equal(actual, expected); | ||
it('FN should accept a custom eval function', () => { | ||
const custom = { | ||
equalsSquirm: left => left === 'squirm', | ||
}; | ||
let left = 'squirm'; | ||
let actual = FN('equalsSquirm', custom)(left); | ||
let expected = true; | ||
expect(actual).toEqual(expected); | ||
|
||
left = 'notsquirm'; | ||
actual = FN('equalsSquirm', custom)(left); | ||
expected = false; | ||
assert.equal(actual, expected, 'custom FN should return false if it is false'); | ||
left = 'notsquirm'; | ||
actual = FN('equalsSquirm', custom)(left); | ||
expected = false; | ||
expect(actual).toEqual(expected); | ||
|
||
left = 'squirm'; | ||
actual = FN('!equalsSquirm', custom)(left); /* ? */ | ||
expected = false; | ||
assert.equal(actual, expected, 'custom FN should accept the ! param to invert the response'); | ||
assert.end(); | ||
}); | ||
left = 'squirm'; | ||
actual = FN('!equalsSquirm', custom)(left); | ||
expected = false; | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('FN should catch and console.log if there is an error', (assert) => { | ||
assert.doesNotThrow(() => FN()(), 'Does not throw if called with nothing'); | ||
assert.end(); | ||
it('should log if there is an error', () => { | ||
global.console = { log: jest.fn() }; | ||
FN('nah')('left', 'right'); // function does not exist | ||
expect(console.log).toBeCalled(); // eslint-disable-line | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
import test from 'tape'; | ||
import dateAfterInclusive from './date-after-inclusive'; | ||
|
||
test('dateAfterInclusive should return true if left is greater than the right.', (assert) => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/01/1975'; | ||
const expected = true; | ||
const actual = dateAfterInclusive(examine, [constraint]); | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
test('dateAfterInclusive should return true for equal dates', (assert) => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/02/1975'; | ||
const expected = true; | ||
const actual = dateAfterInclusive(examine, [constraint]); | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
test('dateAfterInclusive should return false for a date greater than the left date.', (assert) => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/03/1975'; | ||
const expected = false; | ||
const actual = dateAfterInclusive(examine, [constraint]); | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
test('dateAfterInclusive should throw an error for invalid arguments.', (assert) => { | ||
const nonDateString = 'not a date'; | ||
const number = 3513513155; | ||
const bool = true; | ||
const valid = '01/01/1975'; | ||
assert.throws(() => dateAfterInclusive(nonDateString, [valid]), `${nonDateString} should throw an error.`); | ||
assert.throws(() => dateAfterInclusive(number, [valid]), `${number} should throw an error.`); | ||
assert.throws(() => dateAfterInclusive(bool, [valid]), `${bool} should throw an error.`); | ||
assert.end(); | ||
}); | ||
describe('dateAfterInclusive', () => { | ||
it('dateAfterInclusive should return true if left is greater than the right.', () => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/01/1975'; | ||
const expected = true; | ||
const actual = dateAfterInclusive(examine, [constraint]); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('dateAfterInclusive should return true for equal dates', () => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/02/1975'; | ||
const expected = true; | ||
const actual = dateAfterInclusive(examine, [constraint]); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('dateAfterInclusive should return false for a date greater than the left date.', () => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/03/1975'; | ||
const expected = false; | ||
const actual = dateAfterInclusive(examine, [constraint]); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('dateAfterInclusive should throw an error for invalid arguments.', () => { | ||
const nonDateString = 'not a date'; | ||
const number = 3513513155; | ||
const bool = true; | ||
const valid = '01/01/1975'; | ||
expect(() => dateAfterInclusive(nonDateString, [valid])).toThrow('date-after-inclusive: Left and right must both be date formatted strings'); | ||
expect(() => dateAfterInclusive(number, [valid])).toThrow('date-after-inclusive: Left and right must both be date formatted strings'); | ||
expect(() => dateAfterInclusive(bool, [valid])).toThrow('date-after-inclusive: Left and right must both be date formatted strings'); | ||
}); | ||
|
||
it('dateAfterInclusive should throw if there is no input and/or no params', () => { | ||
const input = undefined; | ||
const args = ['']; | ||
expect(() => dateAfterInclusive(input, args)).toThrow('date-after-inclusive: Left and right are both required for the date-after-inclusive predicate'); | ||
}); | ||
|
||
test('dateAfterInclusive should throw if there is no input and/or no params', (assert) => { | ||
const input = undefined; | ||
const args = ['']; | ||
assert.throws(() => dateAfterInclusive(input, args)); | ||
assert.end(); | ||
it('dateAfterInclusive should throw if either left or only right are undefined', () => { | ||
expect(() => dateAfterInclusive(undefined, '01/02/1975')).toThrow('date-after-inclusive: Left and right are both required for the date-after-inclusive predicate'); | ||
expect(() => dateAfterInclusive('01/02/1975', undefined)).toThrow('date-after-inclusive: Left and right are both required for the date-after-inclusive predicate'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
import test from 'tape'; | ||
import dateBeforeInclusive from './date-before-inclusive'; | ||
|
||
test('dateBeforeInclusive should return true if left is less than the constraint.', (assert) => { | ||
const examine = '01/01/1975'; | ||
const constraint = '01/02/1975'; | ||
const expected = true; | ||
const actual = dateBeforeInclusive(examine, constraint); | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
test('dateBeforeInclusive should return true for equal dates', (assert) => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/02/1975'; | ||
const expected = true; | ||
const actual = dateBeforeInclusive(examine, constraint); | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
test('dateBeforeInclusive should return false for a date greater than the left date.', (assert) => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/01/1975'; | ||
const expected = false; | ||
const actual = dateBeforeInclusive(examine, constraint); | ||
assert.equal(actual, expected); | ||
assert.end(); | ||
}); | ||
test('dateBeforeInclusive should throw an error for invalid arguments.', (assert) => { | ||
const nonDateString = 'not a date'; | ||
const number = 3513513155; | ||
const bool = true; | ||
const valid = '01/01/1975'; | ||
assert.throws(() => dateBeforeInclusive(nonDateString, valid), `${nonDateString} should throw an error. Case 1`); | ||
assert.throws(() => dateBeforeInclusive(number, valid), `${number} should throw an error. Case 2`); | ||
assert.throws(() => dateBeforeInclusive(bool, valid), `${bool} should throw an error. Case 3`); | ||
assert.throws(() => dateBeforeInclusive(undefined, valid), 'Should throw an error. Case 4'); | ||
assert.throws(() => dateBeforeInclusive(valid, undefined), 'Should throw an error. Case 5'); | ||
assert.end(); | ||
describe('dateBeforeInclusive', () => { | ||
it('dateBeforeInclusive should return true if left is less than the constraint.', () => { | ||
const examine = '01/01/1975'; | ||
const constraint = '01/02/1975'; | ||
const expected = true; | ||
const actual = dateBeforeInclusive(examine, constraint); | ||
expect(actual).toEqual(expected); | ||
}); | ||
it('dateBeforeInclusive should return true for equal dates', () => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/02/1975'; | ||
const expected = true; | ||
const actual = dateBeforeInclusive(examine, constraint); | ||
expect(actual).toEqual(expected); | ||
}); | ||
it('dateBeforeInclusive should return false for a date greater than the left date.', () => { | ||
const examine = '01/02/1975'; | ||
const constraint = '01/01/1975'; | ||
const expected = false; | ||
const actual = dateBeforeInclusive(examine, constraint); | ||
expect(actual).toEqual(expected); | ||
}); | ||
it('dateBeforeInclusive should throw an error for invalid arguments.', () => { | ||
const nonDateString = 'not a date'; | ||
const number = 3513513155; | ||
const bool = true; | ||
const valid = '01/01/1975'; | ||
expect(() => dateBeforeInclusive(nonDateString, valid)).toThrow('date-before-inclusive: Left and right must both be date formatted strings'); | ||
expect(() => dateBeforeInclusive(number, valid)).toThrow('date-before-inclusive: Left and right must both be date formatted strings'); | ||
expect(() => dateBeforeInclusive(bool, valid)).toThrow('date-before-inclusive: Left and right must both be date formatted strings'); | ||
expect(() => dateBeforeInclusive(undefined, valid)).toThrow('date-before-inclusive: Left and right are both required for the date-before-inclusive predicate'); | ||
expect(() => dateBeforeInclusive(valid, undefined)).toThrow('date-before-inclusive: Left and right are both required for the date-before-inclusive predicate'); | ||
}); | ||
|
||
it('dateBeforeInclusive should throw if there is no input and/or no params', () => { | ||
const input = undefined; | ||
const args = ['']; | ||
expect(() => dateBeforeInclusive(input, args)).toThrow('date-before-inclusive: Left and right are both required for the date-before-inclusive predicate'); | ||
}); | ||
}); | ||
|
Oops, something went wrong.