-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmatchers.js
47 lines (33 loc) · 1.04 KB
/
matchers.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
'use strict';
var formatToBe = require('./format/to-be');
var formatToEqual = require('./format/to-equal');
var formatToHaveBeenCalledWith = require('./format/to-have-been-called-with');
var formatToThrow = require('./format/to-throw');
var extend = require('./utils/object').extend;
var DEFAULT_MATCHERS = {
toBe: {
format: formatToBe,
pattern: /Expected ([\S\s]*) to be ([\S\s]*)\./,
reverse: true
},
toEqual: {
format: formatToEqual,
pattern: /Expected ([\S\s]*) to equal ([\S\s]*)\./,
reverse: true
},
toHaveBeenCalledWith: {
format: formatToHaveBeenCalledWith,
pattern: /Expected spy .* to have been called with ([\S\s]*) but actual calls were ([\S\s]*)\./
},
toThrow: {
format: formatToThrow,
pattern: /Expected function to throw ([\S\s]*), but it threw ([\S\s]*)\./
}
};
exports.extend = function (customMatchers) {
customMatchers = customMatchers || {};
var allMatchers = {};
extend(allMatchers, DEFAULT_MATCHERS);
extend(allMatchers, customMatchers);
return allMatchers;
};