-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `none()` for ensuring no entry in an array satisfy the expectation. Remove deprecation for `some()`. While it is equivalent to `has()` with one parameter, there is no harm in using it.
- Loading branch information
Showing
19 changed files
with
5,923 additions
and
3,640 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,30 +48,31 @@ | |
"setupFiles": [ | ||
"<rootDir>/scripts/setup-test-env.js" | ||
], | ||
"testEnvironment": "node", | ||
"testRegex": ".*\\.spec.ts$", | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
".(ts|tsx)": "ts-jest" | ||
} | ||
}, | ||
"author": { | ||
"name": "Homa Wong", | ||
"email": "[email protected]" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^22.2.3", | ||
"@types/node": "^9.6.21", | ||
"assertron": "^5.1.1", | ||
"dependency-check": "^3.1.0", | ||
"eslint": "^4.19.1", | ||
"@types/jest": "^23.3.1", | ||
"@types/node": "^10.5.6", | ||
"assertron": "^5.1.3", | ||
"dependency-check": "^3.2.0", | ||
"eslint": "^5.3.0", | ||
"eslint-plugin-unional": "^1.0.0", | ||
"jest": "^22.4.4", | ||
"power-assert": "^1.5.0", | ||
"jest": "^23.4.2", | ||
"power-assert": "^1.6.0", | ||
"rimraf": "^2.6.2", | ||
"semantic-release": "^15.5.1", | ||
"ts-jest": "^22.4.6", | ||
"tslint": "^5.10.0", | ||
"tslint-config-unional": "^0.9.4", | ||
"typescript": "^2.8.4" | ||
"semantic-release": "^15.9.5", | ||
"ts-jest": "^23.1.2", | ||
"tslint": "^5.11.0", | ||
"tslint-config-unional": "^0.9.6", | ||
"typescript": "^3.0.1" | ||
}, | ||
"dependencies": { | ||
"tersify": "^1.2.6" | ||
|
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import t from 'assert' | ||
import a from 'assertron' | ||
|
||
import { createSatisfier, none } from './index' | ||
|
||
test('non array returns false', () => { | ||
a.false(createSatisfier(none({ a: 1 })).test(true)) | ||
a.false(createSatisfier(none({ a: 1 })).test(1)) | ||
a.false(createSatisfier(none({ a: 1 })).test('{ a: 1 }')) | ||
a.false(createSatisfier(none({ a: 1 })).test({ a: 1 })) | ||
}) | ||
|
||
test('array with no match returns true', () => { | ||
t(createSatisfier(none({ a: 1 })).test([{ b: 1 }])) | ||
}) | ||
|
||
test('array with one match returns false', () => { | ||
a.false(createSatisfier(none({ a: 1 })).test([{ a: 1 }])) | ||
a.false(createSatisfier(none({ a: 1 })).test([{ b: 1 }, { a: 1 }])) | ||
}) | ||
|
||
test('tersify()', () => { | ||
t.strictEqual(none({ a: 1 }).tersify(), 'none({ a: 1 })') | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
tersible, | ||
tersify, | ||
// @ts-ignore | ||
Tersible | ||
} from 'tersify' | ||
|
||
import { createSatisfier } from './createSatisfier' | ||
|
||
/** | ||
* Check if an array have no entry satisfying the expectation. | ||
* @param expectation expectation | ||
*/ | ||
export function none(expectation) { | ||
const s = createSatisfier(expectation) | ||
return tersible(e => e && Array.isArray(e) && !e.some(v => s.test(v)), () => `none(${tersify(expectation)})`) | ||
} |
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
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