-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreeter.test.js
More file actions
32 lines (32 loc) · 958 Bytes
/
greeter.test.js
File metadata and controls
32 lines (32 loc) · 958 Bytes
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
expect.extend({
toHaveBeenCalledWithSome: function (received, argument) {
var a = received.calls.allArgs()[0][0];
argument(a);
return {
message: function () { return ""; },
pass: true
};
}
});
var greeter = {
welcome: function (name) {
var action = {
message: "Hi " + name
};
console.log(action);
}
};
describe("greeter", function () {
it("'welcome' creates action with welcome message", function () {
spyOn(console, "log");
var name = "John";
greeter.welcome(name);
expect(console.log).toHaveBeenCalled();
expect(console.log).toHaveBeenCalledWithSome(function (action) {
expect(action).toBeTruthy();
expect(action.message).toContain("Welcome");
expect(action.message).toContain(name);
expect(action.message).toBe("Welcome " + name);
});
});
});