forked from sinonjs/sinon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend-test.js
60 lines (47 loc) · 1.83 KB
/
extend-test.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
57
58
59
60
(function (root) {
"use strict";
var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert,
refute = buster.refute;
buster.testCase("sinon.extend", {
"should return unaltered target when only one argument": function () {
var target = { hello: "world" };
sinon.extend(target);
assert.equals(target, { hello: "world" });
},
"should copy all (own) properties into first argument, from all subsequent arguments": function () {
var target = { hello: "world" };
sinon.extend(target, { a: "a" }, { b: "b" });
assert.equals(target.hello, "world");
assert.equals(target.a, "a");
assert.equals(target.b, "b");
},
"should copy toString method into target": function () {
var target = {
hello: "world",
toString: function () {
return "hello world";
}
},
source = {
toString: function () {
return "hello source";
}
};
sinon.extend(target, source);
assert.same(target.toString, source.toString);
},
"must copy the last occuring property into the target": function () {
var target = { a: 0, b: 0, c: 0, d: 0 },
source1 = { a: 1, b: 1, c: 1 },
source2 = { a: 2, b: 2 },
soruce3 = { a: 3 };
sinon.extend(target, source1, source2, soruce3);
assert.equals(target.a, 3);
assert.equals(target.b, 2);
assert.equals(target.c, 1);
assert.equals(target.d, 0);
}
});
}(this));