Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Add test for Set.containEql
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Dec 27, 2017
1 parent cc2f68b commit 120e3d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions test/.eslintrc.yml
@@ -0,0 +1,4 @@
extends: ../

env:
node: true
23 changes: 15 additions & 8 deletions test/ext/contain.test.js
Expand Up @@ -11,15 +11,13 @@ describe("contain*", function() {

({}.should.not.containEql({ a: 10 }));

if (typeof Set === "function") {
new Set([1, 2, 3]).should.containEql(new Set([1]));
}

({ b: 10 }.should.containEql({ b: 10 }));
[1, 2, 3].should.containEql(1);
[1, 2, { a: 10 }].should.containEql({ a: 10 });
[1, 2, 3].should.not.containEql({ a: 1 });

new Set([1, 2, 3]).should.containEql(1);

err(function() {
[1, 2, 3].should.not.containEql(3);
}, "expected Array [ 1, 2, 3 ] not to contain 3 (false negative fail)");
Expand All @@ -35,7 +33,9 @@ describe("contain*", function() {
b: { c: 10, d: 11, a: { b: 10, c: 11 } }
}.should.containDeep({ a: { b: 10 }, b: { c: 10, a: { c: 11 } } }));

[1, 2, 3, { a: { b: { d: 12 } } }].should.containDeep([{ a: { b: { d: 12 } } }]);
[1, 2, 3, { a: { b: { d: 12 } } }].should.containDeep([
{ a: { b: { d: 12 } } }
]);

[[1, [2, 3], 3], [2]].should.not.containDeep([1, 2]);

Expand All @@ -55,7 +55,10 @@ describe("contain*", function() {

["code-for-days", "code"].should.containDeep(["code", "code-for-days"]);
({ a: "hello" }.should.not.containDeep({ a: ["hello"] }));
["code-for-days", "code-fast"].should.containDeep(["code-fast", "code-for-days"]);
["code-for-days", "code-fast"].should.containDeep([
"code-fast",
"code-for-days"
]);

err(function() {
[{ a: "a" }, { b: "b", c: "c" }].should.not.containDeep([{ b: "b" }]);
Expand All @@ -78,7 +81,9 @@ describe("contain*", function() {
b: { c: 10, d: 11, a: { b: 10, c: 11 } }
}.should.containDeepOrdered({ a: { b: 10 }, b: { c: 10, a: { c: 11 } } }));

[1, 2, 3, { a: { b: { d: 12 } } }].should.containDeepOrdered([{ a: { b: { d: 12 } } }]);
[1, 2, 3, { a: { b: { d: 12 } } }].should.containDeepOrdered([
{ a: { b: { d: 12 } } }
]);

[[1, [2, 3], 3], [2]].should.not.containDeepOrdered([1, 2]);

Expand All @@ -90,7 +95,9 @@ describe("contain*", function() {
[{ a: "a" }, { b: "b", c: "c" }].should.containDeepOrdered([{ b: "b" }]);

err(function() {
[{ a: "a" }, { b: "b", c: "c" }].should.not.containDeepOrdered([{ b: "b" }]);
[{ a: "a" }, { b: "b", c: "c" }].should.not.containDeepOrdered([
{ b: "b" }
]);
}, "expected Array [ Object { a: 'a' }, Object { b: 'b', c: 'c' } ] not to contain Array [ Object { b: 'b' } ] (false negative fail)");

({ hi: null }.should.containEql({ hi: null }));
Expand Down

0 comments on commit 120e3d9

Please sign in to comment.