forked from summernote/summernote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chaidom.js
58 lines (47 loc) · 1.81 KB
/
chaidom.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
define([
'summernote/base/core/agent'
], function (agent) {
return function (chai) {
chai.dom = chai.dom || {};
chai.dom.equalsIgnoreCase = function (str1, str2) {
str1 = str1.toUpperCase();
str2 = str2.toUpperCase();
// [workaround] IE8-10 use instead of bogus br
if (agent.isMSIE && agent.browserVersion < 11) {
str2 = str2.replace(/<BR\/?>/g, '&NBSP;');
str1 = str1.replace(/<BR\/?>/g, '&NBSP;');
}
// [workaround] IE8 str1 markup has newline between tags
if (agent.isMSIE && agent.browserVersion < 9) {
str1 = str1.replace(/\r\n/g, '');
}
return str1 === str2;
};
chai.dom.equalsStyle = function ($node, expected, style) {
var $tester = $('<div />').css(style, expected);
return $node.css(style) === $tester.css(style);
};
chai.Assertion.addChainableMethod('equalsIgnoreCase', function (expected) {
var actual = this._obj;
return this.assert(
chai.dom.equalsIgnoreCase(actual, expected),
'expected ' + this._obj + ' to equal ' + expected + ' ignoring case',
'expected ' + this._obj + ' not to equal ' + expected + ' ignoring case'
);
});
chai.Assertion.addChainableMethod('equalsStyle', function (expected, style) {
var $node = this._obj;
return this.assert(
chai.dom.equalsStyle($node, expected, style),
'expected ' + this._obj + ' to equal ' + expected + ' style',
'expected ' + this._obj + ' not to equal ' + expected + ' style'
);
});
chai.assert.equalsIgnoreCase = function (val, exp, msg) {
new chai.Assertion(val, msg).to.be.equalsIgnoreCase(exp);
};
chai.assert.notequalsIgnoreCase = function (val, exp, msg) {
new chai.Assertion(val, msg).to.not.be.equalsIgnoreCase(exp);
};
};
});