codeceptjs-chai
Advanced tools
+8
-0
@@ -252,2 +252,10 @@ export = chaiWrapper; | ||
| assertDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude:any, customErrorMsg?: any): any; | ||
| /** | ||
| * Asserts a JSON object matches a provided pattern | ||
| * https://www.chaijs.com/plugins/chai-match-pattern/ | ||
| * @param {*} actualValue | ||
| * @param {*} expectedPattern | ||
| * @param {*} customErrorMsg | ||
| */ | ||
| assertMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: any): any; | ||
| } |
+101
-50
@@ -9,2 +9,3 @@ /* eslint-disable global-require */ | ||
| chai.use( require( 'chai-exclude' ) ); | ||
| chai.use( require( 'chai-match-pattern' ) ); | ||
@@ -28,3 +29,3 @@ /** | ||
| return expect( actualValue, customErrorMsg ).to.equal( expectedValue ); | ||
| } | ||
@@ -43,3 +44,3 @@ | ||
| return expect( actualValue, customErrorMsg ).not.to.equal( expectedValue ); | ||
| } | ||
@@ -58,3 +59,3 @@ | ||
| return expect( actualValue, customErrorMsg ).to.deep.equal( expectedValue ); | ||
| } | ||
@@ -74,3 +75,3 @@ | ||
| return expect( actualValue, customErrorMsg ).to.not.deep.equal( expectedValue ); | ||
| } | ||
@@ -87,4 +88,6 @@ | ||
| return expect( actualValue, customErrorMsg ).to.contain( expectedValueToContain ); | ||
| return expect( actualValue, customErrorMsg ).to.contain( | ||
| expectedValueToContain | ||
| ); | ||
| } | ||
@@ -100,6 +103,12 @@ | ||
| */ | ||
| assertNotContain( actualValue, expectedValueToNotContain, customErrorMsg = '' ){ | ||
| assertNotContain( | ||
| actualValue, | ||
| expectedValueToNotContain, | ||
| customErrorMsg = '' | ||
| ){ | ||
| return expect( actualValue, customErrorMsg ).not.to.contain( expectedValueToNotContain ); | ||
| return expect( actualValue, customErrorMsg ).not.to.contain( | ||
| expectedValueToNotContain | ||
| ); | ||
| } | ||
@@ -116,4 +125,6 @@ | ||
| return expect( actualValue, customErrorMsg ).to.startsWith( expectedValueToStartWith ); | ||
| return expect( actualValue, customErrorMsg ).to.startsWith( | ||
| expectedValueToStartWith | ||
| ); | ||
| } | ||
@@ -129,9 +140,14 @@ | ||
| */ | ||
| assertNotStartsWith( actualValue, expectedValueToNotStartWith, customErrorMsg = '' ){ | ||
| assertNotStartsWith( | ||
| actualValue, | ||
| expectedValueToNotStartWith, | ||
| customErrorMsg = '' | ||
| ){ | ||
| return expect( actualValue, customErrorMsg ).not.to.startsWith( expectedValueToNotStartWith ); | ||
| return expect( actualValue, customErrorMsg ).not.to.startsWith( | ||
| expectedValueToNotStartWith | ||
| ); | ||
| } | ||
| /** | ||
@@ -147,5 +163,5 @@ * https://www.npmjs.com/package/chai-string#endswithendwith | ||
| return expect( actualValue, customErrorMsg ).to.endsWith( | ||
| expectedValueToEndWith, | ||
| expectedValueToEndWith | ||
| ); | ||
| } | ||
@@ -161,8 +177,12 @@ | ||
| */ | ||
| assertNotEndsWith( actualValue, expectedValueToNotEndWith, customErrorMsg = '' ){ | ||
| assertNotEndsWith( | ||
| actualValue, | ||
| expectedValueToNotEndWith, | ||
| customErrorMsg = '' | ||
| ){ | ||
| return expect( actualValue, customErrorMsg ).not.to.endsWith( | ||
| expectedValueToNotEndWith, | ||
| expectedValueToNotEndWith | ||
| ); | ||
| } | ||
@@ -181,3 +201,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.jsonSchema( jsonSchema ); | ||
| } | ||
@@ -197,9 +217,8 @@ | ||
| customErrorMsg = '', | ||
| ajvOptions = { allErrors: true } ){ | ||
| ajvOptions = { allErrors: true } | ||
| ){ | ||
| chai.use( | ||
| require( 'chai-json-schema-ajv' ).create( ajvOptions ) | ||
| ); | ||
| chai.use( require( 'chai-json-schema-ajv' ).create( ajvOptions ) ); | ||
| return expect( targetData, customErrorMsg ).to.be.jsonSchema( jsonSchema ); | ||
| } | ||
@@ -217,3 +236,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.have.property( propertyName ); | ||
| } | ||
@@ -231,3 +250,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.have.a.property( propertyName ); | ||
| } | ||
@@ -245,3 +264,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.a( type ); | ||
| } | ||
@@ -259,3 +278,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.an( type ); | ||
| } | ||
@@ -273,3 +292,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.match( regex ); | ||
| } | ||
@@ -287,3 +306,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.have.lengthOf( length ); | ||
| } | ||
@@ -297,6 +316,6 @@ | ||
| */ | ||
| assertEmpty( targetData, customErrorMsg = '' ){ | ||
| assertEmpty( targetData, customErrorMsg = '' ){ | ||
| return expect( targetData, customErrorMsg ).to.be.empty; | ||
| } | ||
@@ -313,3 +332,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.true; | ||
| } | ||
@@ -326,3 +345,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.false; | ||
| } | ||
@@ -340,3 +359,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.above( aboveThan ); | ||
| } | ||
@@ -354,3 +373,3 @@ | ||
| return expect( targetData, customErrorMsg ).to.be.below( belowThan ); | ||
| } | ||
@@ -368,4 +387,6 @@ | ||
| return expect( targetData, customErrorMsg ).to.have.lengthOf.above( lengthAboveThan ); | ||
| return expect( targetData, customErrorMsg ).to.have.lengthOf.above( | ||
| lengthAboveThan | ||
| ); | ||
| } | ||
@@ -383,4 +404,6 @@ | ||
| return expect( targetData, customErrorMsg ).to.have.lengthOf.below( lengthBelowThan ); | ||
| return expect( targetData, customErrorMsg ).to.have.lengthOf.below( | ||
| lengthBelowThan | ||
| ); | ||
| } | ||
@@ -397,4 +420,6 @@ | ||
| return expect( actualValue, customErrorMsg ).to.equalIgnoreCase( expectedValue ); | ||
| return expect( actualValue, customErrorMsg ).to.equalIgnoreCase( | ||
| expectedValue | ||
| ); | ||
| } | ||
@@ -412,4 +437,6 @@ | ||
| return expect( actualValue, customErrorMsg ).to.have.deep.members( expectedValue ); | ||
| return expect( actualValue, customErrorMsg ).to.have.deep.members( | ||
| expectedValue | ||
| ); | ||
| } | ||
@@ -427,7 +454,10 @@ | ||
| return expect( actualValue, customErrorMsg ).to.deep.include.members( expectedValue ); | ||
| return expect( actualValue, customErrorMsg ).to.deep.include.members( | ||
| expectedValue | ||
| ); | ||
| } | ||
| /** | ||
| * Asserts members of two JSON objects are deeply equal excluding some properties | ||
| * https://www.chaijs.com/api/bdd/#method_deep | ||
@@ -442,6 +472,27 @@ * https://www.chaijs.com/plugins/chai-exclude/ | ||
| */ | ||
| assertDeepEqualExcluding( actualValue, expectedValue, fieldsToExclude, customErrorMsg = '' ){ | ||
| assertDeepEqualExcluding( | ||
| actualValue, | ||
| expectedValue, | ||
| fieldsToExclude, | ||
| customErrorMsg = '' | ||
| ){ | ||
| return expect( actualValue, customErrorMsg ).excludingEvery( fieldsToExclude ).to.deep.equal( expectedValue ); | ||
| return expect( actualValue, customErrorMsg ) | ||
| .excludingEvery( fieldsToExclude ) | ||
| .to.deep.equal( expectedValue ); | ||
| } | ||
| /** | ||
| * Asserts a JSON object matches a provided pattern | ||
| * https://www.chaijs.com/plugins/chai-match-pattern/ | ||
| * @param {*} actualValue | ||
| * @param {*} expectedPattern | ||
| * @param {*} customErrorMsg | ||
| * @returns | ||
| */ | ||
| assertMatchesPattern( actualValue, expectedPattern, customErrorMsg = '' ){ | ||
| return expect( actualValue, customErrorMsg ).to.matchPattern( expectedPattern ); | ||
| } | ||
@@ -448,0 +499,0 @@ |
+3
-2
| { | ||
| "name": "codeceptjs-chai", | ||
| "version": "2.3.3", | ||
| "version": "2.3.4", | ||
| "description": "CodeceptJS helper for chai library", | ||
| "devDependencies": { | ||
| "codeceptjs": "^2.5.0", | ||
| "codeceptjs": "^3.4.1", | ||
| "eslint": "^5.16.0", | ||
@@ -19,2 +19,3 @@ "eslint-config-airbnb-base": "^13.1.0", | ||
| "chai-json-schema-ajv": "^5.1.0", | ||
| "chai-match-pattern": "^1.3.0", | ||
| "chai-string": "^1.5.0" | ||
@@ -21,0 +22,0 @@ }, |
+238
-144
@@ -18,7 +18,7 @@ # codeceptjs-chai | ||
| { | ||
| "helpers": { | ||
| "ChaiWrapper" : { | ||
| "require": "codeceptjs-chai" | ||
| } | ||
| } | ||
| "helpers": { | ||
| "ChaiWrapper": { | ||
| "require": "codeceptjs-chai" | ||
| } | ||
| } | ||
| } | ||
@@ -35,4 +35,4 @@ ``` | ||
| I.assertEqual(1, 1); | ||
| I.assertEqual('foo', 'foo'); | ||
| I.assertEqual('foo', 'foo', 'Both the values are not equal'); | ||
| I.assertEqual("foo", "foo"); | ||
| I.assertEqual("foo", "foo", "Both the values are not equal"); | ||
| ``` | ||
@@ -50,9 +50,9 @@ | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.chaijs.com/api/bdd/#method_equal | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.chaijs.com/api/bdd/#method_equal | ||
| ```js | ||
| I.assertNotEqual(2, 1); | ||
| I.assertNotEqual('foobar', 'foo'); | ||
| I.assertNotEqual('foobar', 'foo', 'Both the values are equal'); | ||
| I.assertNotEqual("foobar", "foo"); | ||
| I.assertNotEqual("foobar", "foo", "Both the values are equal"); | ||
| ``` | ||
@@ -70,7 +70,7 @@ | ||
| - https://www.chaijs.com/api/bdd/#method_deep | ||
| - https://www.chaijs.com/api/bdd/#method_equal | ||
| - https://www.chaijs.com/api/bdd/#method_deep | ||
| - https://www.chaijs.com/api/bdd/#method_equal | ||
| ```js | ||
| I.assertDeepEqual({a: 1}, {a: 1}); | ||
| I.assertDeepEqual({ a: 1 }, { a: 1 }); | ||
| ``` | ||
@@ -88,10 +88,14 @@ | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.chaijs.com/api/bdd/#method_deep | ||
| - https://www.chaijs.com/api/bdd/#method_equal | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.chaijs.com/api/bdd/#method_deep | ||
| - https://www.chaijs.com/api/bdd/#method_equal | ||
| ```js | ||
| I.assertNotDeepEqual({a: 1}, {a: 2}); | ||
| I.assertNotDeepEqual({a: 1}, {b: 1, c: 2}); | ||
| I.assertNotDeepEqual({a: 1}, {b: 1, c: 2}, 'Both the values are deeply equal'); | ||
| I.assertNotDeepEqual({ a: 1 }, { a: 2 }); | ||
| I.assertNotDeepEqual({ a: 1 }, { b: 1, c: 2 }); | ||
| I.assertNotDeepEqual( | ||
| { a: 1 }, | ||
| { b: 1, c: 2 }, | ||
| "Both the values are deeply equal" | ||
| ); | ||
| ``` | ||
@@ -112,8 +116,14 @@ | ||
| ```js | ||
| I.assertContain('foobar', 'foo'); | ||
| I.assertContain("foobar", "foo"); | ||
| I.assertContain([1, 2, 3], 2); | ||
| I.assertContain({a: 1, b: 2, c: 3}, {a: 1, b: 2}); | ||
| I.assertContain({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 }); | ||
| I.assertContain(new Set([1, 2]), 2); | ||
| I.assertContain(new Map([['a', 1], ['b', 2]]), 2); | ||
| I.assertContain('foobar', 'foo', 'Target value does not contain given value'); | ||
| I.assertContain( | ||
| new Map([ | ||
| ["a", 1], | ||
| ["b", 2], | ||
| ]), | ||
| 2 | ||
| ); | ||
| I.assertContain("foobar", "foo", "Target value does not contain given value"); | ||
| ``` | ||
@@ -131,10 +141,10 @@ | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.chaijs.com/api/bdd/#method_include | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.chaijs.com/api/bdd/#method_include | ||
| ```js | ||
| I.assertNotContain('foo', 'bar'); | ||
| I.assertNotContain("foo", "bar"); | ||
| I.assertNotContain([1, 2, 3], 4); | ||
| I.assertNotContain({a: 3, b: 4}, {a: 1, b: 2}); | ||
| I.assertNotContain('foo', 'bar', 'Target value contains given value'); | ||
| I.assertNotContain({ a: 3, b: 4 }, { a: 1, b: 2 }); | ||
| I.assertNotContain("foo", "bar", "Target value contains given value"); | ||
| ``` | ||
@@ -155,4 +165,8 @@ | ||
| ```js | ||
| I.assertStartsWith('foobar', 'foo'); | ||
| I.assertStartsWith('foobar', 'foo', 'Target value does not start with given value'); | ||
| I.assertStartsWith("foobar", "foo"); | ||
| I.assertStartsWith( | ||
| "foobar", | ||
| "foo", | ||
| "Target value does not start with given value" | ||
| ); | ||
| ``` | ||
@@ -170,8 +184,8 @@ | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.npmjs.com/package/chai-string#startswithstartwith | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.npmjs.com/package/chai-string#startswithstartwith | ||
| ```js | ||
| I.assertNotStartsWith('foobar', 'bar'); | ||
| I.assertNotStartsWith('foobar', 'bar', 'Target value starts with given value'); | ||
| I.assertNotStartsWith("foobar", "bar"); | ||
| I.assertNotStartsWith("foobar", "bar", "Target value starts with given value"); | ||
| ``` | ||
@@ -192,4 +206,8 @@ | ||
| ```js | ||
| I.assertEndsWith('foobar', 'bar'); | ||
| I.assertEndsWith('foobar', 'bar', 'Target value does not ends with given value'); | ||
| I.assertEndsWith("foobar", "bar"); | ||
| I.assertEndsWith( | ||
| "foobar", | ||
| "bar", | ||
| "Target value does not ends with given value" | ||
| ); | ||
| ``` | ||
@@ -207,8 +225,8 @@ | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.npmjs.com/package/chai-string#endswithendwith | ||
| - https://www.chaijs.com/api/bdd/#method_not | ||
| - https://www.npmjs.com/package/chai-string#endswithendwith | ||
| ```js | ||
| I.assertNotEndsWith('foobar', 'bar'); | ||
| I.assertNotEndsWith('foobar', 'bar', 'Target value ends with given value'); | ||
| I.assertNotEndsWith("foobar", "bar"); | ||
| I.assertNotEndsWith("foobar", "bar", "Target value ends with given value"); | ||
| ``` | ||
@@ -230,35 +248,39 @@ | ||
| const goodApple = { | ||
| skin: 'thin', | ||
| colors: ['red', 'green', 'yellow'], | ||
| taste: 10 | ||
| skin: "thin", | ||
| colors: ["red", "green", "yellow"], | ||
| taste: 10, | ||
| }; | ||
| const badApple = { | ||
| colors: ['brown'], | ||
| taste: 0, | ||
| worms: 2 | ||
| colors: ["brown"], | ||
| taste: 0, | ||
| worms: 2, | ||
| }; | ||
| const fruitSchema = { | ||
| title: 'fresh fruit schema v1', | ||
| type: 'object', | ||
| required: ['skin', 'colors', 'taste'], | ||
| properties: { | ||
| colors: { | ||
| type: 'array', | ||
| minItems: 1, | ||
| uniqueItems: true, | ||
| items: { | ||
| type: 'string' | ||
| } | ||
| 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, | ||
| }, | ||
| }, | ||
| skin: { | ||
| type: 'string' | ||
| }, | ||
| taste: { | ||
| type: 'number', | ||
| minimum: 5 | ||
| } | ||
| } | ||
| }; | ||
| I.assertJsonSchema(goodApple, fruitSchema); | ||
| I.assertJsonSchema(goodApple, fruitSchema, 'Target json data does not conform to json schema'); | ||
| I.assertJsonSchema( | ||
| goodApple, | ||
| fruitSchema, | ||
| "Target json data does not conform to json schema" | ||
| ); | ||
| ``` | ||
@@ -276,41 +298,46 @@ | ||
| - https://www.chaijs.com/plugins/chai-json-schema-ajv/ | ||
| - https://www.npmjs.com/package/chai-json-schema-ajv | ||
| - https://www.chaijs.com/plugins/chai-json-schema-ajv/ | ||
| - https://www.npmjs.com/package/chai-json-schema-ajv | ||
| ```js | ||
| const goodApple = { | ||
| skin: 'thin', | ||
| colors: ['red', 'green', 'yellow'], | ||
| taste: 10 | ||
| skin: "thin", | ||
| colors: ["red", "green", "yellow"], | ||
| taste: 10, | ||
| }; | ||
| const badApple = { | ||
| colors: ['brown'], | ||
| taste: 0, | ||
| worms: 2 | ||
| colors: ["brown"], | ||
| taste: 0, | ||
| worms: 2, | ||
| }; | ||
| const fruitSchema = { | ||
| title: 'fresh fruit schema v1', | ||
| type: 'object', | ||
| required: ['skin', 'colors', 'taste'], | ||
| properties: { | ||
| colors: { | ||
| type: 'array', | ||
| minItems: 1, | ||
| uniqueItems: true, | ||
| items: { | ||
| type: 'string' | ||
| } | ||
| 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, | ||
| }, | ||
| }, | ||
| skin: { | ||
| type: 'string' | ||
| }, | ||
| taste: { | ||
| type: 'number', | ||
| minimum: 5 | ||
| } | ||
| } | ||
| }; | ||
| I.assertJsonSchemaUsingAJV(goodApple, fruitSchema); | ||
| I.assertJsonSchema(goodApple, fruitSchema, 'Target json data does not conform to json schema', {}); | ||
| I.assertJsonSchema(goodApple, fruitSchema, '', { jsonPointers: true }); | ||
| I.assertJsonSchema( | ||
| goodApple, | ||
| fruitSchema, | ||
| "Target json data does not conform to json schema", | ||
| {} | ||
| ); | ||
| I.assertJsonSchema(goodApple, fruitSchema, "", { jsonPointers: true }); | ||
| ``` | ||
@@ -332,4 +359,8 @@ | ||
| ```js | ||
| I.assertHasProperty({a: 1}, 'a'); | ||
| I.assertHasProperty({a: 1}, 'a', 'Target data does not have the given property'); | ||
| I.assertHasProperty({ a: 1 }, "a"); | ||
| I.assertHasProperty( | ||
| { a: 1 }, | ||
| "a", | ||
| "Target data does not have the given property" | ||
| ); | ||
| ``` | ||
@@ -350,4 +381,8 @@ | ||
| ```js | ||
| I.assertHasAProperty({b: 2}, 'b'); | ||
| I.assertHasAProperty({b: 2}, 'b', 'Target data does not have a child property with the given key'); | ||
| I.assertHasAProperty({ b: 2 }, "b"); | ||
| I.assertHasAProperty( | ||
| { b: 2 }, | ||
| "b", | ||
| "Target data does not have a child property with the given key" | ||
| ); | ||
| ``` | ||
@@ -368,8 +403,8 @@ | ||
| ```js | ||
| I.assertToBeA('foo', 'string'); | ||
| I.assertToBeA(null, 'null'); | ||
| I.assertToBeA(Promise.resolve(), 'promise'); | ||
| I.assertToBeA(new Float32Array, 'float32array'); | ||
| I.assertToBeA(Symbol(), 'symbol'); | ||
| I.assertToBeA('foo', 'string', 'Target data does not match the type'); | ||
| I.assertToBeA("foo", "string"); | ||
| I.assertToBeA(null, "null"); | ||
| I.assertToBeA(Promise.resolve(), "promise"); | ||
| I.assertToBeA(new Float32Array(), "float32array"); | ||
| I.assertToBeA(Symbol(), "symbol"); | ||
| I.assertToBeA("foo", "string", "Target data does not match the type"); | ||
| ``` | ||
@@ -390,7 +425,7 @@ | ||
| ```js | ||
| I.assertToBeAn([1, 2, 3], 'array'); | ||
| I.assertToBeAn({a: 1}, 'object'); | ||
| I.assertToBeAn(undefined, 'undefined'); | ||
| I.assertToBeAn(new Error, 'error'); | ||
| I.assertToBeAn([1, 2, 3], 'array', 'Target data does not match the type'); | ||
| I.assertToBeAn([1, 2, 3], "array"); | ||
| I.assertToBeAn({ a: 1 }, "object"); | ||
| I.assertToBeAn(undefined, "undefined"); | ||
| I.assertToBeAn(new Error(), "error"); | ||
| I.assertToBeAn([1, 2, 3], "array", "Target data does not match the type"); | ||
| ``` | ||
@@ -411,4 +446,8 @@ | ||
| ```js | ||
| I.assertMatchRegex('foobar', /^foo/); | ||
| I.assertMatchRegex('foobar', /^foo/, 'Target data does not match the given regex'); | ||
| I.assertMatchRegex("foobar", /^foo/); | ||
| I.assertMatchRegex( | ||
| "foobar", | ||
| /^foo/, | ||
| "Target data does not match the given regex" | ||
| ); | ||
| ``` | ||
@@ -430,6 +469,13 @@ | ||
| I.assertLengthOf([1, 2, 3], 3); | ||
| I.assertLengthOf('foo', 3); | ||
| I.assertLengthOf("foo", 3); | ||
| I.assertLengthOf(new Set([1, 2, 3]), 3); | ||
| I.assertLengthOf(new Map([['a', 1], ['b', 2], ['c', 3]]), 3); | ||
| I.assertLengthOf('foo', 3, 'Target data does not match the length'); | ||
| I.assertLengthOf( | ||
| new Map([ | ||
| ["a", 1], | ||
| ["b", 2], | ||
| ["c", 3], | ||
| ]), | ||
| 3 | ||
| ); | ||
| I.assertLengthOf("foo", 3, "Target data does not match the length"); | ||
| ``` | ||
@@ -450,3 +496,3 @@ | ||
| ```js | ||
| I.assertEmpty(''); | ||
| I.assertEmpty(""); | ||
| I.assertEmpty([]); | ||
@@ -456,3 +502,3 @@ I.assertEmpty({}); | ||
| I.assertEmpty(new Map()); | ||
| I.assertEmpty('', 'Target data is not empty'); | ||
| I.assertEmpty("", "Target data is not empty"); | ||
| ``` | ||
@@ -473,3 +519,3 @@ | ||
| I.assertTrue(true); | ||
| I.assertTrue(true, 'Target data is not true'); | ||
| I.assertTrue(true, "Target data is not true"); | ||
| ``` | ||
@@ -490,3 +536,3 @@ | ||
| I.assertFalse(false); | ||
| I.assertTrue(false, 'Target data is not false'); | ||
| I.assertTrue(false, "Target data is not false"); | ||
| ``` | ||
@@ -507,3 +553,3 @@ | ||
| I.assertAbove(2, 1); | ||
| I.assertAbove(2, 1, 'Target data not above the given value'); | ||
| I.assertAbove(2, 1, "Target data not above the given value"); | ||
| ``` | ||
@@ -525,3 +571,3 @@ | ||
| I.assertBelow(1, 2); | ||
| I.assertAbove(1, 2, 'Target data not below the given value'); | ||
| I.assertAbove(1, 2, "Target data not below the given value"); | ||
| ``` | ||
@@ -543,6 +589,17 @@ | ||
| I.assertLengthOf([1, 2, 3], 3); | ||
| I.assertLengthOf('foo', 3); | ||
| I.assertLengthOf("foo", 3); | ||
| I.assertLengthOf(new Set([1, 2, 3]), 3); | ||
| I.assertLengthOf(new Map([['a', 1], ['b', 2], ['c', 3]]), 3); | ||
| I.assertLengthOf('foo', 3, 'Target length or size does not match the given number'); | ||
| I.assertLengthOf( | ||
| new Map([ | ||
| ["a", 1], | ||
| ["b", 2], | ||
| ["c", 3], | ||
| ]), | ||
| 3 | ||
| ); | ||
| I.assertLengthOf( | ||
| "foo", | ||
| 3, | ||
| "Target length or size does not match the given number" | ||
| ); | ||
| ``` | ||
@@ -565,6 +622,17 @@ | ||
| I.assertLengthAboveThan([1, 2, 3], 2); | ||
| I.assertLengthAboveThan('foo', 2); | ||
| I.assertLengthAboveThan("foo", 2); | ||
| I.assertLengthAboveThan(new Set([1, 2, 3]), 2); | ||
| I.assertLengthAboveThan(new Map([['a', 1], ['b', 2], ['c', 3]]), 2); | ||
| I.assertLengthAboveThan('foo', 2, 'Target length or size not above than given number'); | ||
| I.assertLengthAboveThan( | ||
| new Map([ | ||
| ["a", 1], | ||
| ["b", 2], | ||
| ["c", 3], | ||
| ]), | ||
| 2 | ||
| ); | ||
| I.assertLengthAboveThan( | ||
| "foo", | ||
| 2, | ||
| "Target length or size not above than given number" | ||
| ); | ||
| ``` | ||
@@ -587,6 +655,17 @@ | ||
| I.assertLengthBelowThan([1, 2, 3], 4); | ||
| I.assertLengthBelowThan('foo', 4); | ||
| I.assertLengthBelowThan("foo", 4); | ||
| I.assertLengthBelowThan(new Set([1, 2, 3]), 4); | ||
| I.assertLengthBelowThan(new Map([['a', 1], ['b', 2], ['c', 3]]), 4); | ||
| I.assertLengthAboveThan('foo', 4, 'Target length or size not below than given number'); | ||
| I.assertLengthBelowThan( | ||
| new Map([ | ||
| ["a", 1], | ||
| ["b", 2], | ||
| ["c", 3], | ||
| ]), | ||
| 4 | ||
| ); | ||
| I.assertLengthAboveThan( | ||
| "foo", | ||
| 4, | ||
| "Target length or size not below than given number" | ||
| ); | ||
| ``` | ||
@@ -607,3 +686,3 @@ | ||
| ```js | ||
| I.assertEqualIgnoreCase('FOO','foo') | ||
| I.assertEqualIgnoreCase("FOO", "foo"); | ||
| ``` | ||
@@ -624,3 +703,3 @@ | ||
| ```js | ||
| I.assertDeepMembers([{a: 1}],[{a: 1}]) | ||
| I.assertDeepMembers([{ a: 1 }], [{ a: 1 }]); | ||
| ``` | ||
@@ -641,3 +720,3 @@ | ||
| ```js | ||
| I.assertDeepIncludeMembers([{a: 1},{b: 2}],[{a: 1}]) | ||
| I.assertDeepIncludeMembers([{ a: 1 }, { b: 2 }], [{ a: 1 }]); | ||
| ``` | ||
@@ -647,9 +726,8 @@ | ||
| - `actualValue` - actual value | ||
| - `expectedValue` - expected value | ||
| - `customErrorMsg` - Custom error message | ||
| - `actualValue` - actual value | ||
| - `expectedValue` - expected value | ||
| - `customErrorMsg` - Custom error message | ||
| ## assertDeepExcludeMembers | ||
| ## assertDeepIncludeMembers | ||
| Asserts members of two JSON objects are deeply equal excluding some properties | ||
@@ -660,3 +738,3 @@ | ||
| ```js | ||
| I.assertDeepEqualExcluding([{a: 1},{b: 2}],'b',[{a: 1}]) | ||
| I.assertDeepEqualExcluding([{ a: 1 }, { b: 2 }], "b", [{ a: 1 }]); | ||
| ``` | ||
@@ -666,5 +744,21 @@ | ||
| - `actualValue` - actual value | ||
| - `expectedValue` - expected value | ||
| - `fieldsToExclude` - Fields to exclude from validation | ||
| - `customErrorMsg` - Custom error message | ||
| - `actualValue` - actual value | ||
| - `expectedValue` - expected value | ||
| - `fieldsToExclude` - Fields to exclude from validation | ||
| - `customErrorMsg` - Custom error message | ||
| ## assertMatchesPattern | ||
| Asserts a JSON object matches a provided pattern | ||
| https://www.chaijs.com/plugins/chai-match-pattern/ | ||
| ```js | ||
| I.assertMatchesPattern({ a: 1, b: "abc" }, { a: 1, b: _.isString }); | ||
| ``` | ||
| **Parameters** | ||
| - `actualValue` - actual value | ||
| - `expectedPattern` - pattern to match on | ||
| - `customErrorMsg` - Custom error message |
+54
-17
@@ -5,8 +5,23 @@ { | ||
| "additionalProperties": true, | ||
| "required": ["page", "per_page", "total", "total_pages", "data", "ad"], | ||
| "required": [ | ||
| "page", | ||
| "per_page", | ||
| "total", | ||
| "total_pages", | ||
| "data", | ||
| "support" | ||
| ], | ||
| "properties": { | ||
| "page": { "type": "integer" }, | ||
| "per_page": { "type": "integer" }, | ||
| "total": { "type": "integer" }, | ||
| "total_pages": { "type": "integer" }, | ||
| "page": { | ||
| "type": "integer" | ||
| }, | ||
| "per_page": { | ||
| "type": "integer" | ||
| }, | ||
| "total": { | ||
| "type": "integer" | ||
| }, | ||
| "total_pages": { | ||
| "type": "integer" | ||
| }, | ||
| "data": { | ||
@@ -18,23 +33,45 @@ "type": "array", | ||
| "additionalProperties": true, | ||
| "required": ["id", "email", "first_name", "last_name", "avatar"], | ||
| "required": [ | ||
| "id", | ||
| "email", | ||
| "first_name", | ||
| "last_name", | ||
| "avatar" | ||
| ], | ||
| "properties": { | ||
| "id": { "type": "integer" }, | ||
| "email": { "type": "string" }, | ||
| "first_name": { "type": "string" }, | ||
| "last_name": { "type": "string" }, | ||
| "avatar": { "type": "string" } | ||
| "id": { | ||
| "type": "integer" | ||
| }, | ||
| "email": { | ||
| "type": "string" | ||
| }, | ||
| "first_name": { | ||
| "type": "string" | ||
| }, | ||
| "last_name": { | ||
| "type": "string" | ||
| }, | ||
| "avatar": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "ad": { | ||
| "support": { | ||
| "type": "object", | ||
| "additionalProperties": true, | ||
| "required": ["company", "url", "text"], | ||
| "required": [ | ||
| "url", | ||
| "text" | ||
| ], | ||
| "properties": { | ||
| "company": { "type": "string" }, | ||
| "url": { "type": "string" }, | ||
| "text": { "type": "string" } | ||
| "url": { | ||
| "type": "string" | ||
| }, | ||
| "text": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
+54
-17
@@ -5,8 +5,23 @@ { | ||
| "additionalProperties": true, | ||
| "required": ["page", "per_page", "total", "total_pages", "data", "ad"], | ||
| "required": [ | ||
| "page", | ||
| "per_page", | ||
| "total", | ||
| "total_pages", | ||
| "data", | ||
| "support" | ||
| ], | ||
| "properties": { | ||
| "page": { "type": "string" }, | ||
| "per_page": { "type": "integer" }, | ||
| "total": { "type": "integer" }, | ||
| "total_pages": { "type": "integer" }, | ||
| "page": { | ||
| "type": "string" | ||
| }, | ||
| "per_page": { | ||
| "type": "integer" | ||
| }, | ||
| "total": { | ||
| "type": "integer" | ||
| }, | ||
| "total_pages": { | ||
| "type": "integer" | ||
| }, | ||
| "data": { | ||
@@ -18,23 +33,45 @@ "type": "array", | ||
| "additionalProperties": true, | ||
| "required": ["id", "email", "first_name", "last_name", "avatar"], | ||
| "required": [ | ||
| "id", | ||
| "email", | ||
| "first_name", | ||
| "last_name", | ||
| "avatar" | ||
| ], | ||
| "properties": { | ||
| "id": { "type": "integer" }, | ||
| "email": { "type": "string" }, | ||
| "first_name": { "type": "string" }, | ||
| "last_name": { "type": "string" }, | ||
| "avatar": { "type": "string" } | ||
| "id": { | ||
| "type": "integer" | ||
| }, | ||
| "email": { | ||
| "type": "string" | ||
| }, | ||
| "first_name": { | ||
| "type": "string" | ||
| }, | ||
| "last_name": { | ||
| "type": "string" | ||
| }, | ||
| "avatar": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "ad": { | ||
| "support": { | ||
| "type": "object", | ||
| "additionalProperties": true, | ||
| "required": ["company", "url", "text"], | ||
| "required": [ | ||
| "url", | ||
| "text" | ||
| ], | ||
| "properties": { | ||
| "company": { "type": "string" }, | ||
| "url": { "type": "string" }, | ||
| "text": { "type": "string" } | ||
| "url": { | ||
| "type": "string" | ||
| }, | ||
| "text": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
45504
6.74%840
18.14%731
14.76%7
16.67%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added