Skip to content

Commit

Permalink
refactor(core): convert to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Dec 23, 2018
1 parent 5592065 commit 3e2868a
Show file tree
Hide file tree
Showing 165 changed files with 6,805 additions and 10,589 deletions.
4 changes: 2 additions & 2 deletions jest.config.js
Expand Up @@ -12,8 +12,8 @@ module.exports = {
},
moduleFileExtensions: ['ts', 'tsx', 'js'],
setupTestFrameworkScriptFile: '<rootDir>/test/setup.js',
testMatch: ['<rootDir>/test/**/*.spec.(ts|tsx|js)'],
testMatch: ['<rootDir>/test/**/*.spec.(ts|js)'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.ts$': 'ts-jest'
}
};
10,119 changes: 0 additions & 10,119 deletions package-lock.json

This file was deleted.

28 changes: 14 additions & 14 deletions package.json
Expand Up @@ -25,32 +25,32 @@
"ik9999 (https://github.com/ik9999)"
],
"dependencies": {
"add-matchers": "0.5.0"
"add-matchers": "0.6.0"
},
"devDependencies": {
"@types/jest": "23.3.8",
"@types/node": "10.12.0",
"codeclimate-test-reporter": "0.5.0",
"@types/jest": "23.3.10",
"@types/node": "10.12.18",
"codeclimate-test-reporter": "0.5.1",
"globby": "8.0.1",
"jasmine-core": "3.2.1",
"jasmine-core": "3.3.0",
"jest": "23.6.0",
"karma": "3.0.0",
"karma": "3.1.4",
"karma-browserstack-launcher": "1.3.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-cli": "2.0.0",
"karma-coverage": "1.1.2",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "1.1.2",
"karma-jasmine": "2.0.1",
"karma-nested-reporter": "0.1.6",
"npm-run-all": "4.1.5",
"prettier": "1.14.3",
"prettier": "1.15.3",
"rimraf": "2.6.2",
"saucelabs": "1.5.0",
"ts-jest": "23.10.4",
"ts-loader": "5.3.1",
"tslint": "5.11.0",
"typescript": "3.1.3",
"webpack": "4.27.1",
"ts-jest": "23.10.5",
"ts-loader": "5.3.2",
"tslint": "5.12.0",
"typescript": "3.2.2",
"webpack": "4.28.2",
"webpack-cli": "3.1.2"
},
"homepage": "https://github.com/JamieMason/Jasmine-Matchers",
Expand Down
28 changes: 28 additions & 0 deletions src/asymmetricMatchersByName.ts
@@ -0,0 +1,28 @@
export { default as after } from './toBeAfter';
export { default as arrayOfBooleans } from './toBeArrayOfBooleans';
export { default as arrayOfNumbers } from './toBeArrayOfNumbers';
export { default as arrayOfObjects } from './toBeArrayOfObjects';
export { default as arrayOfSize } from './toBeArrayOfSize';
export { default as arrayOfStrings } from './toBeArrayOfStrings';
export { default as before } from './toBeBefore';
export { default as calculable } from './toBeCalculable';
export { default as emptyArray } from './toBeEmptyArray';
export { default as emptyObject } from './toBeEmptyObject';
export { default as endingWith } from './toEndWith';
export { default as evenNumber } from './toBeEvenNumber';
export { default as greaterThanOrEqualTo } from './toBeGreaterThanOrEqualTo';
export { default as iso8601 } from './toBeIso8601';
export { default as jsonString } from './toBeJsonString';
export { default as lessThanOrEqualTo } from './toBeLessThanOrEqualTo';
export { default as longerThan } from './toBeLongerThan';
export { default as nonEmptyArray } from './toBeNonEmptyArray';
export { default as nonEmptyObject } from './toBeNonEmptyObject';
export { default as nonEmptyString } from './toBeNonEmptyString';
export { default as oddNumber } from './toBeOddNumber';
export { default as regExp } from './toBeRegExp';
export { default as sameLengthAs } from './toBeSameLengthAs';
export { default as shorterThan } from './toBeShorterThan';
export { default as startingWith } from './toStartWith';
export { default as whitespace } from './toBeWhitespace';
export { default as wholeNumber } from './toBeWholeNumber';
export { default as withinRange } from './toBeWithinRange';
119 changes: 0 additions & 119 deletions src/index.js

This file was deleted.

8 changes: 8 additions & 0 deletions src/index.ts
@@ -0,0 +1,8 @@
import addMatchers from 'add-matchers';
import * as asymmetricMatchersByName from './asymmetricMatchersByName';
import * as matchersByName from './matchersByName';

addMatchers(matchersByName);
addMatchers.asymmetric(asymmetricMatchersByName);

export default matchersByName;
2 changes: 1 addition & 1 deletion src/lib/every.js → src/lib/every.ts
@@ -1,4 +1,4 @@
module.exports = (array, truthTest) => {
export default (array, truthTest) => {
for (let i = 0, len = array.length; i < len; i++) {
if (!truthTest(array[i])) {
return false;
Expand Down
20 changes: 0 additions & 20 deletions src/lib/is.js

This file was deleted.

18 changes: 18 additions & 0 deletions src/lib/is.ts
@@ -0,0 +1,18 @@
const createIs = (type) => (value) =>
Object.prototype.toString.call(value) === `[object ${type}]`;

const createIsBooleanObject = (trueOrFalse) => (value) =>
is.Boolean(value) && value.valueOf() === trueOrFalse;

const is = {
Array: createIs('Array'),
Boolean: createIs('Boolean'),
Date: createIs('Date'),
False: createIsBooleanObject(false),
Function: createIs('Function'),
Object: createIs('Object'),
String: createIs('String'),
True: createIsBooleanObject(true)
};

export default is;
4 changes: 0 additions & 4 deletions src/lib/keys.js

This file was deleted.

4 changes: 4 additions & 0 deletions src/lib/keys.ts
@@ -0,0 +1,4 @@
import reduce from './reduce';

export default (object) =>
reduce(object, (keys, value, key) => keys.concat(key), []);
4 changes: 0 additions & 4 deletions src/lib/memberMatcherFor.js

This file was deleted.

4 changes: 4 additions & 0 deletions src/lib/memberMatcherFor.ts
@@ -0,0 +1,4 @@
import is from './is';

export default (toBeX) => (key, actual) =>
is.Object(actual) && toBeX(actual[key]);
4 changes: 2 additions & 2 deletions src/lib/reduce.js → src/lib/reduce.ts
@@ -1,6 +1,6 @@
const is = require("./is");
import is from './is';

module.exports = (collection, fn, memo) => {
export default (collection, fn, memo) => {
if (is.Array(collection)) {
for (let i = 0, len = collection.length; i < len; i++) {
memo = fn(memo, collection[i], i, collection);
Expand Down
83 changes: 83 additions & 0 deletions src/matchersByName.ts
@@ -0,0 +1,83 @@
export { default as toBeAfter } from './toBeAfter';
export { default as toBeArray } from './toBeArray';
export { default as toBeArrayOfBooleans } from './toBeArrayOfBooleans';
export { default as toBeArrayOfNumbers } from './toBeArrayOfNumbers';
export { default as toBeArrayOfObjects } from './toBeArrayOfObjects';
export { default as toBeArrayOfSize } from './toBeArrayOfSize';
export { default as toBeArrayOfStrings } from './toBeArrayOfStrings';
export { default as toBeBefore } from './toBeBefore';
export { default as toBeBoolean } from './toBeBoolean';
export { default as toBeCalculable } from './toBeCalculable';
export { default as toBeDate } from './toBeDate';
export { default as toBeEmptyArray } from './toBeEmptyArray';
export { default as toBeEmptyObject } from './toBeEmptyObject';
export { default as toBeEmptyString } from './toBeEmptyString';
export { default as toBeEvenNumber } from './toBeEvenNumber';
export { default as toBeFalse } from './toBeFalse';
export { default as toBeFunction } from './toBeFunction';
export {
default as toBeGreaterThanOrEqualTo
} from './toBeGreaterThanOrEqualTo';
export { default as toBeHtmlString } from './toBeHtmlString';
export { default as toBeIso8601 } from './toBeIso8601';
export { default as toBeJsonString } from './toBeJsonString';
export { default as toBeLessThanOrEqualTo } from './toBeLessThanOrEqualTo';
export { default as toBeLongerThan } from './toBeLongerThan';
export { default as toBeNear } from './toBeNear';
export { default as toBeNonEmptyArray } from './toBeNonEmptyArray';
export { default as toBeNonEmptyObject } from './toBeNonEmptyObject';
export { default as toBeNonEmptyString } from './toBeNonEmptyString';
export { default as toBeNumber } from './toBeNumber';
export { default as toBeObject } from './toBeObject';
export { default as toBeOddNumber } from './toBeOddNumber';
export { default as toBeRegExp } from './toBeRegExp';
export { default as toBeSameLengthAs } from './toBeSameLengthAs';
export { default as toBeShorterThan } from './toBeShorterThan';
export { default as toBeString } from './toBeString';
export { default as toBeTrue } from './toBeTrue';
export { default as toBeValidDate } from './toBeValidDate';
export { default as toBeWhitespace } from './toBeWhitespace';
export { default as toBeWholeNumber } from './toBeWholeNumber';
export { default as toBeWithinRange } from './toBeWithinRange';
export { default as toEndWith } from './toEndWith';
export { default as toHaveArray } from './toHaveArray';
export { default as toHaveArrayOfBooleans } from './toHaveArrayOfBooleans';
export { default as toHaveArrayOfNumbers } from './toHaveArrayOfNumbers';
export { default as toHaveArrayOfObjects } from './toHaveArrayOfObjects';
export { default as toHaveArrayOfSize } from './toHaveArrayOfSize';
export { default as toHaveArrayOfStrings } from './toHaveArrayOfStrings';
export { default as toHaveBoolean } from './toHaveBoolean';
export { default as toHaveCalculable } from './toHaveCalculable';
export { default as toHaveDate } from './toHaveDate';
export { default as toHaveDateAfter } from './toHaveDateAfter';
export { default as toHaveDateBefore } from './toHaveDateBefore';
export { default as toHaveEmptyArray } from './toHaveEmptyArray';
export { default as toHaveEmptyObject } from './toHaveEmptyObject';
export { default as toHaveEmptyString } from './toHaveEmptyString';
export { default as toHaveEvenNumber } from './toHaveEvenNumber';
export { default as toHaveFalse } from './toHaveFalse';
export { default as toHaveHtmlString } from './toHaveHtmlString';
export { default as toHaveIso8601 } from './toHaveIso8601';
export { default as toHaveJsonString } from './toHaveJsonString';
export { default as toHaveMember } from './toHaveMember';
export { default as toHaveMethod } from './toHaveMethod';
export { default as toHaveNonEmptyArray } from './toHaveNonEmptyArray';
export { default as toHaveNonEmptyObject } from './toHaveNonEmptyObject';
export { default as toHaveNonEmptyString } from './toHaveNonEmptyString';
export { default as toHaveNumber } from './toHaveNumber';
export { default as toHaveNumberWithinRange } from './toHaveNumberWithinRange';
export { default as toHaveObject } from './toHaveObject';
export { default as toHaveOddNumber } from './toHaveOddNumber';
export { default as toHaveString } from './toHaveString';
export { default as toHaveStringLongerThan } from './toHaveStringLongerThan';
export {
default as toHaveStringSameLengthAs
} from './toHaveStringSameLengthAs';
export { default as toHaveStringShorterThan } from './toHaveStringShorterThan';
export { default as toHaveTrue } from './toHaveTrue';
export { default as toHaveUndefined } from './toHaveUndefined';
export { default as toHaveWhitespaceString } from './toHaveWhitespaceString';
export { default as toHaveWholeNumber } from './toHaveWholeNumber';
export { default as toStartWith } from './toStartWith';
export { default as toThrowAnyError } from './toThrowAnyError';
export { default as toThrowErrorOfType } from './toThrowErrorOfType';
3 changes: 0 additions & 3 deletions src/toBeAfter.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/toBeAfter.ts
@@ -0,0 +1,2 @@
import toBeBefore from './toBeBefore';
export default (otherDate, actual) => toBeBefore(actual, otherDate);
3 changes: 0 additions & 3 deletions src/toBeArray.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/toBeArray.ts
@@ -0,0 +1,2 @@
import is from './lib/is';
export default is.Array;
5 changes: 0 additions & 5 deletions src/toBeArrayOfBooleans.js

This file was deleted.

4 changes: 4 additions & 0 deletions src/toBeArrayOfBooleans.ts
@@ -0,0 +1,4 @@
import every from './lib/every';
import toBeArray from './toBeArray';
import toBeBoolean from './toBeBoolean';
export default (actual) => toBeArray(actual) && every(actual, toBeBoolean);

0 comments on commit 3e2868a

Please sign in to comment.