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
1 parent
2971f15
commit 661a21f
Showing
25 changed files
with
643 additions
and
509 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,12 +1,14 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": "error" | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"env": { | ||
"mocha": true | ||
}, | ||
"extends": ".eslintrc.json" | ||
} |
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 |
---|---|---|
|
@@ -9,5 +9,6 @@ cache: | |
install: | ||
- npm install | ||
script: | ||
- npm run lint | ||
- npm run coveralls | ||
- npm run build |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
export default class Spec { | ||
constructor(name = '', options) { | ||
constructor(name = "", options) { | ||
// options is data necessary to check values for conformity | ||
this.options = options | ||
this.options = options; | ||
// name is for better display when printing explain() result | ||
this.name = name | ||
this.name = name; | ||
} | ||
|
||
conform(value) { | ||
throw new Error(`Implement in subclass: conform(${value})`) | ||
throw new Error(`Implement in subclass: conform(${value})`); | ||
} | ||
|
||
unform(conformed) { | ||
throw new Error(`Implement in subclass: unform(${conformed})`) | ||
throw new Error(`Implement in subclass: unform(${conformed})`); | ||
} | ||
|
||
explain(value) { | ||
throw new Error(`Implement in subclass: explain(${value})`) | ||
throw new Error(`Implement in subclass: explain(${value})`); | ||
} | ||
} |
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,8 +1,8 @@ | ||
// returned from conform() if value is invalid according to spec | ||
export const invalid = Symbol("invalid") | ||
export const invalid = Symbol("invalid"); | ||
// used for map spec, denotes optional keys | ||
export const optional = Symbol("optional") | ||
export const optional = Symbol("optional"); | ||
// used for collection spec | ||
export const count = Symbol("count") | ||
export const minCount = Symbol("minCount") | ||
export const maxCount = Symbol("maxCount") | ||
export const count = Symbol("count"); | ||
export const minCount = Symbol("minCount"); | ||
export const maxCount = Symbol("maxCount"); |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import {expect} from 'chai' | ||
import {assert} from '../index' | ||
import {number} from '../lib/predicates' | ||
import { expect } from "chai"; | ||
import { assert } from "../index"; | ||
import { number } from "../lib/predicates"; | ||
|
||
describe("index", () => { | ||
describe("assert", () => { | ||
it("does not throw an Error when valid", () => { | ||
expect(() => assert(number, 1)).to.not.throw(Error) | ||
}) | ||
expect(() => assert(number, 1)).to.not.throw(Error); | ||
}); | ||
|
||
it("throws an Error when invalid", () => { | ||
expect(() => assert(number, "string")).to.throw(Error, "isNumber") | ||
}) | ||
}) | ||
}) | ||
expect(() => assert(number, "string")).to.throw(Error, "isNumber"); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.