-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.spec.js
56 lines (41 loc) · 1.45 KB
/
index.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"use strict";
var matchers = require("./index");
describe("matcher", function() {
beforeEach(function() {
this.addMatchers(matchers);
});
describe("toHaveIdsMatching", function() {
it("passes when 'actual' has 'id' fields contains the expected values", function() {
var objects = [ { id: 1, name: "bim" },
{ id: 2, name: "bam" },
{ id: 3, name: "busse" }];
expect(objects).toHaveIdsMatching([1,2,3]);
});
it("fails when id-values differ from expected values", function() {
var objects = [ { id: 1 },
{ id: 2 },
{ id: 3 }];
expect(objects).not.toHaveIdsMatching([4,5,6]);
});
it("fails when 'actual' has less than expected", function() {
var objects = [ { id: 1 },
{ id: 2 }];
expect(objects).not.toHaveIdsMatching([1,2,3]);
});
it("fails when 'actual' has an more items than expected", function() {
var objects = [ { id: 1 },
{ id: 2 }];
expect(objects).not.toHaveIdsMatching([1]);
});
it("ignores ordering", function() {
var objects = [ { id: 1 },
{ id: 2 }];
expect(objects).toHaveIdsMatching([2,1]);
});
it("fails when id-field is missing", function() {
var objects = [ { x: 1 },
{ id: 2 }];
expect(objects).not.toHaveIdsMatching([1,2]);
});
});
});