js-spec-chai
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -30,3 +30,2 @@ /** | ||
conform(spec: object): void; | ||
addMethod(name: string, fn: (value: any) => void): void; | ||
} | ||
@@ -33,0 +32,0 @@ } |
{ | ||
"name": "js-spec-chai", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Chai plugin for js.spec", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# js-spec-chai | ||
Chai plugin for js.spec | ||
### Usage | ||
The only addition to `Chai.Assertion` is the `conform` method with accepts the `Spec` object to test against. | ||
Examples can be found in `test/index.test.ts`, but the gist of it is show below: | ||
``` | ||
import * as s from "js.spec" | ||
import * as chai from "chai"; | ||
import jsSpecChai from "../src/index"; | ||
// fancy chai dancing | ||
chai.use(jsSpecChai); | ||
chai.should(); | ||
describe("js-spec-chai", () => { | ||
context("with nested maps", () => { | ||
const school = s.spec.map("schoolSpec", { | ||
city: s.string | ||
}); | ||
const friend = s.spec.map("friendSpec", { | ||
name: s.spec.string, | ||
age: s.spec.number, | ||
school | ||
}); | ||
it("conforms a good object", () => { | ||
const obj = { | ||
name: "andrea", | ||
age: 18, | ||
school: { | ||
city: "Turin", | ||
} | ||
}; | ||
obj.should.conform(friend); | ||
}) | ||
it("does not conform is there is a missing key", () => { | ||
const obj = { | ||
name: "andrea", | ||
school: { | ||
city: "Turin", | ||
} | ||
}; | ||
obj.should.not.conform(friend); | ||
}); | ||
}); | ||
}); | ||
``` | ||
#### License | ||
@@ -5,0 +55,0 @@ |
@@ -35,3 +35,2 @@ // Type definitions for [js-spec-chai] [0.1.0] | ||
conform(spec: object): void; | ||
addMethod(name: string, fn: (value: any) => void): void; | ||
} | ||
@@ -38,0 +37,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13137
82
165