mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 15:00:26 +00:00
Add type definitions for chai-json-schema (#13036)
* Add type definitions for chai-json-schema * Change to types-2.0 style * Change reference path * Fix namespace name * Fix should example in tests
This commit is contained in:
committed by
Masahiro Wakame
parent
c32938577f
commit
60d039d626
@@ -0,0 +1,56 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
|
||||
import { expect } from 'chai';
|
||||
import { assert } from 'chai';
|
||||
|
||||
import chai = require('chai');
|
||||
import ChaiJsonSchema = require('chai-json-schema');
|
||||
|
||||
chai.use(ChaiJsonSchema);
|
||||
chai.should();
|
||||
|
||||
let goodApple = {
|
||||
skin: 'thin',
|
||||
colors: ['red', 'green', 'yellow'],
|
||||
taste: 10
|
||||
};
|
||||
|
||||
let badApple = {
|
||||
colors: ['brown'],
|
||||
taste: 0,
|
||||
worms: 2
|
||||
};
|
||||
|
||||
let fruitSchema = {
|
||||
title: 'fresh fruit schema v1',
|
||||
type: 'object',
|
||||
required: ['skin', 'colors', 'taste'],
|
||||
properties: {
|
||||
colors: {
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
skin: {
|
||||
type: 'string'
|
||||
},
|
||||
taste: {
|
||||
type: 'number',
|
||||
minimum: 5
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//bdd style
|
||||
expect(goodApple).to.be.jsonSchema(fruitSchema);
|
||||
expect(badApple).to.not.be.jsonSchema(fruitSchema);
|
||||
|
||||
goodApple.should.be.jsonSchema(fruitSchema);
|
||||
badApple.should.not.be.jsonSchema(fruitSchema);
|
||||
|
||||
//tdd style
|
||||
assert.jsonSchema(goodApple, fruitSchema);
|
||||
assert.notJsonSchema(badApple, fruitSchema);
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for chai-json-schema 1.4
|
||||
// Project: https://github.com/chaijs/chai-json-schema/
|
||||
// Definitions by: Ulrich Heiniger <https://github.com/ulrichheiniger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// <reference types="node"/>
|
||||
// <reference types="chai" />
|
||||
|
||||
declare namespace Chai {
|
||||
export interface Assert {
|
||||
jsonSchema(value: any, schema: any, msg?: string): void;
|
||||
notJsonSchema(value: any, schema: any, msg?: string): void;
|
||||
}
|
||||
|
||||
export interface LanguageChains {
|
||||
jsonSchema(schema: any, msg?: string): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "chai-json-schema" {
|
||||
function chaiJsonSchema(chai: any, utils: any): void;
|
||||
namespace chaiJsonSchema {}
|
||||
export = chaiJsonSchema;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"chai-json-schema-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{ "extends": "../tslint.json",
|
||||
"rules": {
|
||||
"no-single-declare-module": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user