mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Added definitions for chai-subset
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/// <reference path="chai-subset.d.ts" />
|
||||
|
||||
import chai = require('chai');
|
||||
import chaiSubset = require('chai-subset');
|
||||
|
||||
chai.use(chaiSubset);
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
|
||||
function test_containSubset() {
|
||||
var obj: Object = {
|
||||
a: 'b',
|
||||
c: 'd',
|
||||
e: {
|
||||
foo: 'bar',
|
||||
baz: {
|
||||
qux: 'quux'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(obj).to.containSubset({
|
||||
a: 'b',
|
||||
e: {
|
||||
baz: {
|
||||
qux: 'quux'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
obj.should.containSubset({ a: 'b' });
|
||||
}
|
||||
|
||||
function test_notContainSubset() {
|
||||
var obj: Object = {
|
||||
a: 'b',
|
||||
c: 'd',
|
||||
e: {
|
||||
foo: 'bar',
|
||||
baz: {
|
||||
qux: 'quux'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(obj).to.not.containSubset({ g: 'whatever' });
|
||||
obj.should.not.containSubset({ g: 'whatever' });
|
||||
}
|
||||
|
||||
function test_arrayContainSubset() {
|
||||
var list: Array<Object> = [{a: 'a', b: 'b'}, {v: 'f', d: {z: 'g'}} ];
|
||||
|
||||
expect(list).to.containSubset([{a:'a', b: 'b'}]);
|
||||
list.should.containSubset([{a:'a', b: 'b'}]);
|
||||
}
|
||||
|
||||
function test_arrayNotContainSubset() {
|
||||
var list: Array<Object> = [{a: 'a', b: 'b'}, {v: 'f', d: {z: 'g'}} ];
|
||||
|
||||
expect(list).not.to.containSubset([{a:'a', b: 'bd'}]);
|
||||
list.should.not.containSubset([{a:'a', b: 'bd'}]);
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for chai-subset 1.0.0
|
||||
// Project: https://github.com/e-conomic/chai-subset
|
||||
// Definitions by: Sam Noedel <https://github.com/delta62/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
|
||||
declare module Chai {
|
||||
interface Assertion {
|
||||
containSubset(obj: Object): Assertion;
|
||||
}
|
||||
}
|
||||
|
||||
interface Object {
|
||||
should: Chai.Assertion;
|
||||
}
|
||||
|
||||
declare module "chai-subset" {
|
||||
function chaiSubset(chai: any, utils: any): void;
|
||||
export = chaiSubset;
|
||||
}
|
||||
Reference in New Issue
Block a user