ende 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +2 -2
- data/components/component/bind/{0.0.1 → 1.0.0}/component.json +1 -1
- data/components/component/bind/{0.0.1 → 1.0.0}/index.js +1 -2
- data/components/component/jquery/1.0.0/component.json +10 -0
- data/components/component/jquery/1.0.0/index.js +10308 -0
- data/components/component/matches-selector/{0.1.2 → 0.1.4}/component.json +1 -1
- data/components/component/matches-selector/{0.1.2 → 0.1.4}/index.js +0 -0
- data/components/indefinido/advisable/master/component.json +1 -1
- data/components/indefinido/indemma/master/component.json +4 -7
- data/components/indefinido/indemma/master/lib/record.js +7 -2
- data/components/indefinido/indemma/master/lib/record/dirtyable.js +15 -6
- data/components/indefinido/indemma/master/lib/record/scopable.js +1 -1
- data/components/indefinido/observable/es6-modules/component.json +1 -1
- data/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +8 -3
- data/components/indefinido/observable/es6-modules/lib/observable.js +0 -1
- data/components/indefinido/observable/es6-modules/lib/observable/observation.js +2 -2
- data/components/paulmillr/es6-shim/{0.10.1 → 0.14.0}/component.json +1 -1
- data/components/paulmillr/es6-shim/{0.10.1 → 0.14.0}/es6-shim.js +151 -102
- data/components/pluma/assimilate/{0.3.0 → 0.4.0}/component.json +2 -2
- data/components/pluma/assimilate/{0.3.0 → 0.4.0}/dist/assimilate.js +1 -1
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +12 -6
- data/lib/assets/javascripts/config/load_components.js.coffee +1 -1
- data/lib/assets/javascripts/ende.js.coffee +1 -1
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/component/build.css +112 -0
- data/vendor/assets/components/ende_build.js +20357 -19584
- metadata +13 -84
- data/components/chaijs/assertion-error/1.0.0/component.json +0 -18
- data/components/chaijs/assertion-error/1.0.0/index.js +0 -110
- data/components/chaijs/chai/1.9.1/.gitignore +0 -22
- data/components/chaijs/chai/1.9.1/.mailmap +0 -1
- data/components/chaijs/chai/1.9.1/.npmignore +0 -14
- data/components/chaijs/chai/1.9.1/.travis.yml +0 -14
- data/components/chaijs/chai/1.9.1/CONTRIBUTING.md +0 -173
- data/components/chaijs/chai/1.9.1/History.md +0 -895
- data/components/chaijs/chai/1.9.1/Makefile +0 -93
- data/components/chaijs/chai/1.9.1/README.md +0 -99
- data/components/chaijs/chai/1.9.1/ReleaseNotes.md +0 -482
- data/components/chaijs/chai/1.9.1/bower.json +0 -27
- data/components/chaijs/chai/1.9.1/chai.js +0 -4782
- data/components/chaijs/chai/1.9.1/component.json +0 -50
- data/components/chaijs/chai/1.9.1/index.js +0 -1
- data/components/chaijs/chai/1.9.1/karma.conf.js +0 -28
- data/components/chaijs/chai/1.9.1/karma.sauce.js +0 -41
- data/components/chaijs/chai/1.9.1/lib/chai.js +0 -87
- data/components/chaijs/chai/1.9.1/lib/chai/assertion.js +0 -130
- data/components/chaijs/chai/1.9.1/lib/chai/config.js +0 -50
- data/components/chaijs/chai/1.9.1/lib/chai/core/assertions.js +0 -1314
- data/components/chaijs/chai/1.9.1/lib/chai/interface/assert.js +0 -1056
- data/components/chaijs/chai/1.9.1/lib/chai/interface/expect.js +0 -12
- data/components/chaijs/chai/1.9.1/lib/chai/interface/should.js +0 -78
- data/components/chaijs/chai/1.9.1/lib/chai/utils/addChainableMethod.js +0 -111
- data/components/chaijs/chai/1.9.1/lib/chai/utils/addMethod.js +0 -43
- data/components/chaijs/chai/1.9.1/lib/chai/utils/addProperty.js +0 -40
- data/components/chaijs/chai/1.9.1/lib/chai/utils/flag.js +0 -32
- data/components/chaijs/chai/1.9.1/lib/chai/utils/getActual.js +0 -18
- data/components/chaijs/chai/1.9.1/lib/chai/utils/getEnumerableProperties.js +0 -25
- data/components/chaijs/chai/1.9.1/lib/chai/utils/getMessage.js +0 -49
- data/components/chaijs/chai/1.9.1/lib/chai/utils/getName.js +0 -20
- data/components/chaijs/chai/1.9.1/lib/chai/utils/getPathValue.js +0 -102
- data/components/chaijs/chai/1.9.1/lib/chai/utils/getProperties.js +0 -35
- data/components/chaijs/chai/1.9.1/lib/chai/utils/index.js +0 -114
- data/components/chaijs/chai/1.9.1/lib/chai/utils/inspect.js +0 -320
- data/components/chaijs/chai/1.9.1/lib/chai/utils/objDisplay.js +0 -49
- data/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteChainableMethod.js +0 -53
- data/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteMethod.js +0 -51
- data/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteProperty.js +0 -54
- data/components/chaijs/chai/1.9.1/lib/chai/utils/test.js +0 -26
- data/components/chaijs/chai/1.9.1/lib/chai/utils/transferFlags.js +0 -44
- data/components/chaijs/chai/1.9.1/lib/chai/utils/type.js +0 -45
- data/components/chaijs/chai/1.9.1/package.json +0 -42
- data/components/chaijs/chai/1.9.1/sauce.browsers.js +0 -128
- data/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_block.sh +0 -7
- data/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_setup.sh +0 -53
- data/components/chaijs/chai/1.9.1/test/assert.js +0 -638
- data/components/chaijs/chai/1.9.1/test/auth/.gitkeep +0 -0
- data/components/chaijs/chai/1.9.1/test/bootstrap/index.js +0 -22
- data/components/chaijs/chai/1.9.1/test/bootstrap/karma.js +0 -22
- data/components/chaijs/chai/1.9.1/test/configuration.js +0 -133
- data/components/chaijs/chai/1.9.1/test/display/errors.js +0 -14
- data/components/chaijs/chai/1.9.1/test/display/message.js +0 -47
- data/components/chaijs/chai/1.9.1/test/expect.js +0 -814
- data/components/chaijs/chai/1.9.1/test/globalShould.js +0 -15
- data/components/chaijs/chai/1.9.1/test/plugins.js +0 -24
- data/components/chaijs/chai/1.9.1/test/should.js +0 -744
- data/components/chaijs/chai/1.9.1/test/utilities.js +0 -309
- data/components/chaijs/deep-eql/0.1.3/component.json +0 -20
- data/components/chaijs/deep-eql/0.1.3/lib/eql.js +0 -257
- data/components/chaijs/type-detect/0.1.1/component.json +0 -18
- data/components/chaijs/type-detect/0.1.1/lib/type.js +0 -142
- data/components/component/classes/1.2.1/component.json +0 -19
- data/components/component/classes/1.2.1/index.js +0 -184
- data/components/component/domify/1.2.2/component.json +0 -22
- data/components/component/domify/1.2.2/index.js +0 -87
- data/components/component/event/0.1.3/component.json +0 -13
- data/components/component/event/0.1.3/index.js +0 -35
- data/components/component/jquery/1.9.1/component.json +0 -14
- data/components/component/jquery/1.9.1/index.js +0 -9601
- data/components/component/query/0.0.3/component.json +0 -23
- data/components/component/query/0.0.3/index.js +0 -21
- data/lib/tasks/.gitkeep +0 -0
File without changes
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Attach chai to global
|
3
|
-
*/
|
4
|
-
|
5
|
-
global.chai = require('../..');
|
6
|
-
|
7
|
-
/*!
|
8
|
-
* Provide check for fail function.
|
9
|
-
*/
|
10
|
-
|
11
|
-
global.err = function (fn, msg) {
|
12
|
-
try {
|
13
|
-
fn();
|
14
|
-
throw new chai.AssertionError({ message: 'Expected an error' });
|
15
|
-
} catch (err) {
|
16
|
-
if ('string' === typeof msg) {
|
17
|
-
chai.expect(err.message).to.equal(msg);
|
18
|
-
} else {
|
19
|
-
chai.expect(err.message).to.match(msg);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
};
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Attach chai to global
|
3
|
-
*/
|
4
|
-
|
5
|
-
global.chai = require('chai');
|
6
|
-
|
7
|
-
/*!
|
8
|
-
* Provide check for fail function.
|
9
|
-
*/
|
10
|
-
|
11
|
-
global.err = function (fn, msg) {
|
12
|
-
try {
|
13
|
-
fn();
|
14
|
-
throw new chai.AssertionError('Expected an error');
|
15
|
-
} catch (err) {
|
16
|
-
if ('string' === typeof msg) {
|
17
|
-
chai.expect(err.message).to.equal(msg);
|
18
|
-
} else {
|
19
|
-
chai.expect(err.message).to.match(msg);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
};
|
@@ -1,133 +0,0 @@
|
|
1
|
-
describe('configuration', function () {
|
2
|
-
var assert = chai.assert;
|
3
|
-
|
4
|
-
var origConfig;
|
5
|
-
|
6
|
-
beforeEach(function() {
|
7
|
-
// backup current config
|
8
|
-
function clone(o) {
|
9
|
-
return JSON.parse(JSON.stringify(o));
|
10
|
-
}
|
11
|
-
origConfig = clone(chai.config);
|
12
|
-
});
|
13
|
-
|
14
|
-
afterEach(function() {
|
15
|
-
// restore config
|
16
|
-
Object.keys(origConfig).forEach(function(key) {
|
17
|
-
chai.config[key] = origConfig[key];
|
18
|
-
});
|
19
|
-
});
|
20
|
-
|
21
|
-
function fooThrows () {
|
22
|
-
chai.expect('foo').to.be.equal('bar');
|
23
|
-
}
|
24
|
-
|
25
|
-
it('includeStack is true', function () {
|
26
|
-
chai.config.includeStack = true;
|
27
|
-
|
28
|
-
try {
|
29
|
-
fooThrows();
|
30
|
-
assert.ok(false, 'should not get here because error thrown');
|
31
|
-
} catch (err) {
|
32
|
-
// not all browsers support err.stack
|
33
|
-
if ('undefined' !== typeof err.stack) {
|
34
|
-
assert.include(err.stack, 'assertEqual', 'should have internal stack trace in error message');
|
35
|
-
assert.include(err.stack, 'fooThrows', 'should have user stack trace in error message');
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
});
|
40
|
-
|
41
|
-
it('includeStack is false', function () {
|
42
|
-
chai.config.includeStack = false;
|
43
|
-
|
44
|
-
try {
|
45
|
-
fooThrows();
|
46
|
-
assert.ok(false, 'should not get here because error thrown');
|
47
|
-
} catch (err) {
|
48
|
-
// IE 10 supports err.stack in Chrome format, but without
|
49
|
-
// `Error.captureStackTrace` support that allows tuning of the error
|
50
|
-
// message.
|
51
|
-
if ('undefined' !== typeof err.stack && 'undefined' !== typeof Error.captureStackTrace) {
|
52
|
-
assert.notInclude(err.stack, 'assertEqual', 'should not have internal stack trace in error message');
|
53
|
-
assert.include(err.stack, 'fooThrows', 'should have user stack trace in error message');
|
54
|
-
}
|
55
|
-
}
|
56
|
-
});
|
57
|
-
|
58
|
-
describe('truncateThreshold', function() {
|
59
|
-
it('is 20', function() {
|
60
|
-
chai.config.truncateThreshold = 20;
|
61
|
-
|
62
|
-
err(function() {
|
63
|
-
assert.deepEqual({v: 'something longer than 20'}, {v: 'x'});
|
64
|
-
}, "expected { Object (v) } to deeply equal { v: 'x' }");
|
65
|
-
});
|
66
|
-
|
67
|
-
it('is 0', function() {
|
68
|
-
chai.config.truncateThreshold = 0;
|
69
|
-
|
70
|
-
err(function() {
|
71
|
-
assert.deepEqual({v: 'something longer than 20'}, {v: 'x'});
|
72
|
-
}, "expected { v: 'something longer than 20' } to deeply equal { v: 'x' }");
|
73
|
-
});
|
74
|
-
});
|
75
|
-
|
76
|
-
describe('deprecated properties', function() {
|
77
|
-
var origWarnFn;
|
78
|
-
var warnings;
|
79
|
-
|
80
|
-
beforeEach(function() {
|
81
|
-
origWarnFn = console.warn;
|
82
|
-
warnings = [];
|
83
|
-
console.warn = function(message) {
|
84
|
-
warnings.push(message);
|
85
|
-
};
|
86
|
-
});
|
87
|
-
|
88
|
-
afterEach(function() {
|
89
|
-
console.warn = origWarnFn;
|
90
|
-
});
|
91
|
-
|
92
|
-
it('Assertion.includeStack warns that it is deprecated', function() {
|
93
|
-
chai.Assertion.includeStack;
|
94
|
-
|
95
|
-
assert.equal(warnings.length, 1);
|
96
|
-
assert.equal(warnings[0], 'Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
97
|
-
|
98
|
-
chai.Assertion.includeStack = true;
|
99
|
-
|
100
|
-
assert.equal(warnings.length, 2);
|
101
|
-
assert.equal(warnings[1], 'Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
102
|
-
});
|
103
|
-
|
104
|
-
it('Assertion.includeStack is kept in sync with config.includeStack', function() {
|
105
|
-
assert.equal(chai.Assertion.includeStack, chai.config.includeStack);
|
106
|
-
chai.Assertion.includeStack = !chai.Assertion.includeStack;
|
107
|
-
assert.equal(chai.Assertion.includeStack, chai.config.includeStack);
|
108
|
-
chai.config.includeStack = !chai.config.includeStack;
|
109
|
-
assert.equal(chai.Assertion.includeStack, chai.config.includeStack);
|
110
|
-
});
|
111
|
-
|
112
|
-
it('Assertion.showDiff warns that it is deprecated', function() {
|
113
|
-
chai.Assertion.showDiff;
|
114
|
-
|
115
|
-
assert.equal(warnings.length, 1);
|
116
|
-
assert.equal(warnings[0], 'Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
117
|
-
|
118
|
-
chai.Assertion.showDiff = true;
|
119
|
-
|
120
|
-
assert.equal(warnings.length, 2);
|
121
|
-
assert.equal(warnings[1], 'Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
122
|
-
});
|
123
|
-
|
124
|
-
it('Assertion.showDiff is kept in sync with config.showDiff', function() {
|
125
|
-
assert.equal(chai.Assertion.showDiff, chai.config.showDiff);
|
126
|
-
chai.Assertion.showDiff = !chai.Assertion.showDiff;
|
127
|
-
assert.equal(chai.Assertion.showDiff, chai.config.showDiff);
|
128
|
-
chai.config.showDiff = !chai.config.showDiff;
|
129
|
-
assert.equal(chai.Assertion.showDiff, chai.config.showDiff);
|
130
|
-
});
|
131
|
-
|
132
|
-
});
|
133
|
-
});
|
@@ -1,47 +0,0 @@
|
|
1
|
-
var chai = require('../..')
|
2
|
-
, expect = chai.expect
|
3
|
-
, should = chai.should();
|
4
|
-
|
5
|
-
var deepObj = {
|
6
|
-
green: { tea: 'matcha' }
|
7
|
-
, teas: [
|
8
|
-
'chai'
|
9
|
-
, 'matcha'
|
10
|
-
, { tea: 'konacha' }
|
11
|
-
]
|
12
|
-
};
|
13
|
-
|
14
|
-
var deepObj2 = {
|
15
|
-
green: { tea: 'matcha' }
|
16
|
-
, teas: [
|
17
|
-
'chai'
|
18
|
-
, 'oolong'
|
19
|
-
, { tea: 'konacha' }
|
20
|
-
]
|
21
|
-
};
|
22
|
-
|
23
|
-
chai.config.includeStack = true;
|
24
|
-
|
25
|
-
suite('object display', function () {
|
26
|
-
|
27
|
-
test('property', function () {
|
28
|
-
deepObj.should.have.property('chai');
|
29
|
-
});
|
30
|
-
|
31
|
-
test('deep equal', function () {
|
32
|
-
deepObj.should.deep.equal(deepObj2);
|
33
|
-
});
|
34
|
-
|
35
|
-
test('deep equal no diff', function () {
|
36
|
-
chai.config.showDiff = false;
|
37
|
-
deepObj.should.deep.equal(deepObj2);
|
38
|
-
chai.config.showDiff = true;
|
39
|
-
});
|
40
|
-
|
41
|
-
});
|
42
|
-
|
43
|
-
suite('undefined/null display', function() {
|
44
|
-
test('undefined for actual', function() {
|
45
|
-
expect(undefined).to.equal(null);
|
46
|
-
});
|
47
|
-
});
|
@@ -1,814 +0,0 @@
|
|
1
|
-
describe('expect', function () {
|
2
|
-
var expect = chai.expect;
|
3
|
-
|
4
|
-
it('chai.version', function() {
|
5
|
-
expect(chai).to.have.property('version');
|
6
|
-
});
|
7
|
-
|
8
|
-
it('assertion', function(){
|
9
|
-
expect('test').to.be.a('string');
|
10
|
-
expect('foo').to.equal('foo');
|
11
|
-
});
|
12
|
-
|
13
|
-
it('true', function(){
|
14
|
-
expect(true).to.be.true;
|
15
|
-
expect(false).to.not.be.true;
|
16
|
-
expect(1).to.not.be.true;
|
17
|
-
|
18
|
-
err(function(){
|
19
|
-
expect('test').to.be.true;
|
20
|
-
}, "expected 'test' to be true")
|
21
|
-
});
|
22
|
-
|
23
|
-
it('ok', function(){
|
24
|
-
expect(true).to.be.ok;
|
25
|
-
expect(false).to.not.be.ok;
|
26
|
-
expect(1).to.be.ok;
|
27
|
-
expect(0).to.not.be.ok;
|
28
|
-
|
29
|
-
err(function(){
|
30
|
-
expect('').to.be.ok;
|
31
|
-
}, "expected '' to be truthy");
|
32
|
-
|
33
|
-
err(function(){
|
34
|
-
expect('test').to.not.be.ok;
|
35
|
-
}, "expected 'test' to be falsy");
|
36
|
-
});
|
37
|
-
|
38
|
-
it('false', function(){
|
39
|
-
expect(false).to.be.false;
|
40
|
-
expect(true).to.not.be.false;
|
41
|
-
expect(0).to.not.be.false;
|
42
|
-
|
43
|
-
err(function(){
|
44
|
-
expect('').to.be.false;
|
45
|
-
}, "expected '' to be false")
|
46
|
-
});
|
47
|
-
|
48
|
-
it('null', function(){
|
49
|
-
expect(null).to.be.null;
|
50
|
-
expect(false).to.not.be.null;
|
51
|
-
|
52
|
-
err(function(){
|
53
|
-
expect('').to.be.null;
|
54
|
-
}, "expected '' to be null")
|
55
|
-
|
56
|
-
});
|
57
|
-
|
58
|
-
it('undefined', function(){
|
59
|
-
expect(undefined).to.be.undefined;
|
60
|
-
expect(null).to.not.be.undefined;
|
61
|
-
|
62
|
-
err(function(){
|
63
|
-
expect('').to.be.undefined;
|
64
|
-
}, "expected '' to be undefined")
|
65
|
-
});
|
66
|
-
|
67
|
-
it('exist', function(){
|
68
|
-
var foo = 'bar'
|
69
|
-
, bar;
|
70
|
-
expect(foo).to.exist;
|
71
|
-
expect(bar).to.not.exist;
|
72
|
-
});
|
73
|
-
|
74
|
-
it('arguments', function(){
|
75
|
-
var args = (function(){ return arguments; })(1,2,3);
|
76
|
-
expect(args).to.be.arguments;
|
77
|
-
expect([]).to.not.be.arguments;
|
78
|
-
expect(args).to.be.an('arguments').and.be.arguments;
|
79
|
-
expect([]).to.be.an('array').and.not.be.Arguments;
|
80
|
-
});
|
81
|
-
|
82
|
-
it('.equal()', function(){
|
83
|
-
var foo;
|
84
|
-
expect(undefined).to.equal(foo);
|
85
|
-
|
86
|
-
err(function(){
|
87
|
-
expect(undefined).to.equal(null);
|
88
|
-
}, "expected undefined to equal null")
|
89
|
-
});
|
90
|
-
|
91
|
-
it('typeof', function(){
|
92
|
-
expect('test').to.be.a('string');
|
93
|
-
|
94
|
-
err(function(){
|
95
|
-
expect('test').to.not.be.a('string');
|
96
|
-
}, "expected 'test' not to be a string");
|
97
|
-
|
98
|
-
(function () {
|
99
|
-
expect(arguments).to.be.an('arguments');
|
100
|
-
})(1, 2);
|
101
|
-
|
102
|
-
expect(5).to.be.a('number');
|
103
|
-
expect(new Number(1)).to.be.a('number');
|
104
|
-
expect(Number(1)).to.be.a('number');
|
105
|
-
expect(true).to.be.a('boolean');
|
106
|
-
expect(new Array()).to.be.a('array');
|
107
|
-
expect(new Object()).to.be.a('object');
|
108
|
-
expect({}).to.be.a('object');
|
109
|
-
expect([]).to.be.a('array');
|
110
|
-
expect(function() {}).to.be.a('function');
|
111
|
-
expect(null).to.be.a('null');
|
112
|
-
|
113
|
-
err(function(){
|
114
|
-
expect(5).to.not.be.a('number', 'blah');
|
115
|
-
}, "blah: expected 5 not to be a number");
|
116
|
-
});
|
117
|
-
|
118
|
-
it('instanceof', function(){
|
119
|
-
function Foo(){}
|
120
|
-
expect(new Foo()).to.be.an.instanceof(Foo);
|
121
|
-
|
122
|
-
err(function(){
|
123
|
-
expect(3).to.an.instanceof(Foo, 'blah');
|
124
|
-
}, "blah: expected 3 to be an instance of Foo");
|
125
|
-
});
|
126
|
-
|
127
|
-
it('within(start, finish)', function(){
|
128
|
-
expect(5).to.be.within(5, 10);
|
129
|
-
expect(5).to.be.within(3,6);
|
130
|
-
expect(5).to.be.within(3,5);
|
131
|
-
expect(5).to.not.be.within(1,3);
|
132
|
-
expect('foo').to.have.length.within(2,4);
|
133
|
-
expect([ 1, 2, 3 ]).to.have.length.within(2,4);
|
134
|
-
|
135
|
-
err(function(){
|
136
|
-
expect(5).to.not.be.within(4,6, 'blah');
|
137
|
-
}, "blah: expected 5 to not be within 4..6", 'blah');
|
138
|
-
|
139
|
-
err(function(){
|
140
|
-
expect(10).to.be.within(50,100, 'blah');
|
141
|
-
}, "blah: expected 10 to be within 50..100");
|
142
|
-
|
143
|
-
err(function () {
|
144
|
-
expect('foo').to.have.length.within(5,7, 'blah');
|
145
|
-
}, "blah: expected \'foo\' to have a length within 5..7");
|
146
|
-
|
147
|
-
err(function () {
|
148
|
-
expect([ 1, 2, 3 ]).to.have.length.within(5,7, 'blah');
|
149
|
-
}, "blah: expected [ 1, 2, 3 ] to have a length within 5..7");
|
150
|
-
});
|
151
|
-
|
152
|
-
it('above(n)', function(){
|
153
|
-
expect(5).to.be.above(2);
|
154
|
-
expect(5).to.be.greaterThan(2);
|
155
|
-
expect(5).to.not.be.above(5);
|
156
|
-
expect(5).to.not.be.above(6);
|
157
|
-
expect('foo').to.have.length.above(2);
|
158
|
-
expect([ 1, 2, 3 ]).to.have.length.above(2);
|
159
|
-
|
160
|
-
err(function(){
|
161
|
-
expect(5).to.be.above(6, 'blah');
|
162
|
-
}, "blah: expected 5 to be above 6", 'blah');
|
163
|
-
|
164
|
-
err(function(){
|
165
|
-
expect(10).to.not.be.above(6, 'blah');
|
166
|
-
}, "blah: expected 10 to be at most 6");
|
167
|
-
|
168
|
-
err(function () {
|
169
|
-
expect('foo').to.have.length.above(4, 'blah');
|
170
|
-
}, "blah: expected \'foo\' to have a length above 4 but got 3");
|
171
|
-
|
172
|
-
err(function () {
|
173
|
-
expect([ 1, 2, 3 ]).to.have.length.above(4, 'blah');
|
174
|
-
}, "blah: expected [ 1, 2, 3 ] to have a length above 4 but got 3");
|
175
|
-
});
|
176
|
-
|
177
|
-
it('least(n)', function(){
|
178
|
-
expect(5).to.be.at.least(2);
|
179
|
-
expect(5).to.be.at.least(5);
|
180
|
-
expect(5).to.not.be.at.least(6);
|
181
|
-
expect('foo').to.have.length.of.at.least(2);
|
182
|
-
expect([ 1, 2, 3 ]).to.have.length.of.at.least(2);
|
183
|
-
|
184
|
-
err(function(){
|
185
|
-
expect(5).to.be.at.least(6, 'blah');
|
186
|
-
}, "blah: expected 5 to be at least 6", 'blah');
|
187
|
-
|
188
|
-
err(function(){
|
189
|
-
expect(10).to.not.be.at.least(6, 'blah');
|
190
|
-
}, "blah: expected 10 to be below 6");
|
191
|
-
|
192
|
-
err(function () {
|
193
|
-
expect('foo').to.have.length.of.at.least(4, 'blah');
|
194
|
-
}, "blah: expected \'foo\' to have a length at least 4 but got 3");
|
195
|
-
|
196
|
-
err(function () {
|
197
|
-
expect([ 1, 2, 3 ]).to.have.length.of.at.least(4, 'blah');
|
198
|
-
}, "blah: expected [ 1, 2, 3 ] to have a length at least 4 but got 3");
|
199
|
-
|
200
|
-
err(function () {
|
201
|
-
expect([ 1, 2, 3, 4 ]).to.not.have.length.of.at.least(4, 'blah');
|
202
|
-
}, "blah: expected [ 1, 2, 3, 4 ] to have a length below 4");
|
203
|
-
});
|
204
|
-
|
205
|
-
it('below(n)', function(){
|
206
|
-
expect(2).to.be.below(5);
|
207
|
-
expect(2).to.be.lessThan(5);
|
208
|
-
expect(2).to.not.be.below(2);
|
209
|
-
expect(2).to.not.be.below(1);
|
210
|
-
expect('foo').to.have.length.below(4);
|
211
|
-
expect([ 1, 2, 3 ]).to.have.length.below(4);
|
212
|
-
|
213
|
-
err(function(){
|
214
|
-
expect(6).to.be.below(5, 'blah');
|
215
|
-
}, "blah: expected 6 to be below 5");
|
216
|
-
|
217
|
-
err(function(){
|
218
|
-
expect(6).to.not.be.below(10, 'blah');
|
219
|
-
}, "blah: expected 6 to be at least 10");
|
220
|
-
|
221
|
-
err(function () {
|
222
|
-
expect('foo').to.have.length.below(2, 'blah');
|
223
|
-
}, "blah: expected \'foo\' to have a length below 2 but got 3");
|
224
|
-
|
225
|
-
err(function () {
|
226
|
-
expect([ 1, 2, 3 ]).to.have.length.below(2, 'blah');
|
227
|
-
}, "blah: expected [ 1, 2, 3 ] to have a length below 2 but got 3");
|
228
|
-
});
|
229
|
-
|
230
|
-
it('most(n)', function(){
|
231
|
-
expect(2).to.be.at.most(5);
|
232
|
-
expect(2).to.be.at.most(2);
|
233
|
-
expect(2).to.not.be.at.most(1);
|
234
|
-
expect(2).to.not.be.at.most(1);
|
235
|
-
expect('foo').to.have.length.of.at.most(4);
|
236
|
-
expect([ 1, 2, 3 ]).to.have.length.of.at.most(4);
|
237
|
-
|
238
|
-
err(function(){
|
239
|
-
expect(6).to.be.at.most(5, 'blah');
|
240
|
-
}, "blah: expected 6 to be at most 5");
|
241
|
-
|
242
|
-
err(function(){
|
243
|
-
expect(6).to.not.be.at.most(10, 'blah');
|
244
|
-
}, "blah: expected 6 to be above 10");
|
245
|
-
|
246
|
-
err(function () {
|
247
|
-
expect('foo').to.have.length.of.at.most(2, 'blah');
|
248
|
-
}, "blah: expected \'foo\' to have a length at most 2 but got 3");
|
249
|
-
|
250
|
-
err(function () {
|
251
|
-
expect([ 1, 2, 3 ]).to.have.length.of.at.most(2, 'blah');
|
252
|
-
}, "blah: expected [ 1, 2, 3 ] to have a length at most 2 but got 3");
|
253
|
-
|
254
|
-
err(function () {
|
255
|
-
expect([ 1, 2 ]).to.not.have.length.of.at.most(2, 'blah');
|
256
|
-
}, "blah: expected [ 1, 2 ] to have a length above 2");
|
257
|
-
});
|
258
|
-
|
259
|
-
it('match(regexp)', function(){
|
260
|
-
expect('foobar').to.match(/^foo/)
|
261
|
-
expect('foobar').to.not.match(/^bar/)
|
262
|
-
|
263
|
-
err(function(){
|
264
|
-
expect('foobar').to.match(/^bar/i, 'blah')
|
265
|
-
}, "blah: expected 'foobar' to match /^bar/i");
|
266
|
-
|
267
|
-
err(function(){
|
268
|
-
expect('foobar').to.not.match(/^foo/i, 'blah')
|
269
|
-
}, "blah: expected 'foobar' not to match /^foo/i");
|
270
|
-
});
|
271
|
-
|
272
|
-
it('length(n)', function(){
|
273
|
-
expect('test').to.have.length(4);
|
274
|
-
expect('test').to.not.have.length(3);
|
275
|
-
expect([1,2,3]).to.have.length(3);
|
276
|
-
|
277
|
-
err(function(){
|
278
|
-
expect(4).to.have.length(3, 'blah');
|
279
|
-
}, 'blah: expected 4 to have a property \'length\'');
|
280
|
-
|
281
|
-
err(function(){
|
282
|
-
expect('asd').to.not.have.length(3, 'blah');
|
283
|
-
}, "blah: expected 'asd' to not have a length of 3");
|
284
|
-
});
|
285
|
-
|
286
|
-
it('eql(val)', function(){
|
287
|
-
expect('test').to.eql('test');
|
288
|
-
expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
|
289
|
-
expect(1).to.eql(1);
|
290
|
-
expect('4').to.not.eql(4);
|
291
|
-
|
292
|
-
err(function(){
|
293
|
-
expect(4).to.eql(3, 'blah');
|
294
|
-
}, 'blah: expected 4 to deeply equal 3');
|
295
|
-
});
|
296
|
-
|
297
|
-
if ('undefined' !== typeof Buffer) {
|
298
|
-
it('Buffer eql()', function () {
|
299
|
-
expect(new Buffer([ 1 ])).to.eql(new Buffer([ 1 ]));
|
300
|
-
|
301
|
-
err(function () {
|
302
|
-
expect(new Buffer([ 0 ])).to.eql(new Buffer([ 1 ]));
|
303
|
-
}, 'expected <Buffer 00> to deeply equal <Buffer 01>');
|
304
|
-
});
|
305
|
-
}
|
306
|
-
|
307
|
-
it('equal(val)', function(){
|
308
|
-
expect('test').to.equal('test');
|
309
|
-
expect(1).to.equal(1);
|
310
|
-
|
311
|
-
err(function(){
|
312
|
-
expect(4).to.equal(3, 'blah');
|
313
|
-
}, 'blah: expected 4 to equal 3');
|
314
|
-
|
315
|
-
err(function(){
|
316
|
-
expect('4').to.equal(4, 'blah');
|
317
|
-
}, "blah: expected '4' to equal 4");
|
318
|
-
});
|
319
|
-
|
320
|
-
it('deep.equal(val)', function(){
|
321
|
-
expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
|
322
|
-
expect({ foo: 'bar' }).not.to.deep.equal({ foo: 'baz' });
|
323
|
-
});
|
324
|
-
|
325
|
-
it('deep.equal(/regexp/)', function(){
|
326
|
-
expect(/a/).to.deep.equal(/a/);
|
327
|
-
expect(/a/).not.to.deep.equal(/b/);
|
328
|
-
expect(/a/).not.to.deep.equal({});
|
329
|
-
expect(/a/g).to.deep.equal(/a/g);
|
330
|
-
expect(/a/g).not.to.deep.equal(/b/g);
|
331
|
-
expect(/a/i).to.deep.equal(/a/i);
|
332
|
-
expect(/a/i).not.to.deep.equal(/b/i);
|
333
|
-
expect(/a/m).to.deep.equal(/a/m);
|
334
|
-
expect(/a/m).not.to.deep.equal(/b/m);
|
335
|
-
});
|
336
|
-
|
337
|
-
it('deep.equal(Date)', function(){
|
338
|
-
var a = new Date(1, 2, 3)
|
339
|
-
, b = new Date(4, 5, 6);
|
340
|
-
expect(a).to.deep.equal(a);
|
341
|
-
expect(a).not.to.deep.equal(b);
|
342
|
-
expect(a).not.to.deep.equal({});
|
343
|
-
});
|
344
|
-
|
345
|
-
it('empty', function(){
|
346
|
-
function FakeArgs() {};
|
347
|
-
FakeArgs.prototype.length = 0;
|
348
|
-
|
349
|
-
expect('').to.be.empty;
|
350
|
-
expect('foo').not.to.be.empty;
|
351
|
-
expect([]).to.be.empty;
|
352
|
-
expect(['foo']).not.to.be.empty;
|
353
|
-
expect(new FakeArgs).to.be.empty;
|
354
|
-
expect({arguments: 0}).not.to.be.empty;
|
355
|
-
expect({}).to.be.empty;
|
356
|
-
expect({foo: 'bar'}).not.to.be.empty;
|
357
|
-
|
358
|
-
err(function(){
|
359
|
-
expect('').not.to.be.empty;
|
360
|
-
}, "expected \'\' not to be empty");
|
361
|
-
|
362
|
-
err(function(){
|
363
|
-
expect('foo').to.be.empty;
|
364
|
-
}, "expected \'foo\' to be empty");
|
365
|
-
|
366
|
-
err(function(){
|
367
|
-
expect([]).not.to.be.empty;
|
368
|
-
}, "expected [] not to be empty");
|
369
|
-
|
370
|
-
err(function(){
|
371
|
-
expect(['foo']).to.be.empty;
|
372
|
-
}, "expected [ \'foo\' ] to be empty");
|
373
|
-
|
374
|
-
err(function(){
|
375
|
-
expect(new FakeArgs).not.to.be.empty;
|
376
|
-
}, "expected { length: 0 } not to be empty");
|
377
|
-
|
378
|
-
err(function(){
|
379
|
-
expect({arguments: 0}).to.be.empty;
|
380
|
-
}, "expected { arguments: 0 } to be empty");
|
381
|
-
|
382
|
-
err(function(){
|
383
|
-
expect({}).not.to.be.empty;
|
384
|
-
}, "expected {} not to be empty");
|
385
|
-
|
386
|
-
err(function(){
|
387
|
-
expect({foo: 'bar'}).to.be.empty;
|
388
|
-
}, "expected { foo: \'bar\' } to be empty");
|
389
|
-
});
|
390
|
-
|
391
|
-
it('property(name)', function(){
|
392
|
-
expect('test').to.have.property('length');
|
393
|
-
expect(4).to.not.have.property('length');
|
394
|
-
|
395
|
-
expect({ 'foo.bar': 'baz' })
|
396
|
-
.to.have.property('foo.bar');
|
397
|
-
expect({ foo: { bar: 'baz' } })
|
398
|
-
.to.not.have.property('foo.bar');
|
399
|
-
|
400
|
-
err(function(){
|
401
|
-
expect('asd').to.have.property('foo');
|
402
|
-
}, "expected 'asd' to have a property 'foo'");
|
403
|
-
err(function(){
|
404
|
-
expect({ foo: { bar: 'baz' } })
|
405
|
-
.to.have.property('foo.bar');
|
406
|
-
}, "expected { foo: { bar: 'baz' } } to have a property 'foo.bar'");
|
407
|
-
});
|
408
|
-
|
409
|
-
it('deep.property(name)', function(){
|
410
|
-
expect({ 'foo.bar': 'baz'})
|
411
|
-
.to.not.have.deep.property('foo.bar');
|
412
|
-
expect({ foo: { bar: 'baz' } })
|
413
|
-
.to.have.deep.property('foo.bar');
|
414
|
-
|
415
|
-
err(function(){
|
416
|
-
expect({ 'foo.bar': 'baz' })
|
417
|
-
.to.have.deep.property('foo.bar');
|
418
|
-
}, "expected { 'foo.bar': 'baz' } to have a deep property 'foo.bar'");
|
419
|
-
});
|
420
|
-
|
421
|
-
it('property(name, val)', function(){
|
422
|
-
expect('test').to.have.property('length', 4);
|
423
|
-
expect('asd').to.have.property('constructor', String);
|
424
|
-
|
425
|
-
err(function(){
|
426
|
-
expect('asd').to.have.property('length', 4, 'blah');
|
427
|
-
}, "blah: expected 'asd' to have a property 'length' of 4, but got 3");
|
428
|
-
|
429
|
-
err(function(){
|
430
|
-
expect('asd').to.not.have.property('length', 3, 'blah');
|
431
|
-
}, "blah: expected 'asd' to not have a property 'length' of 3");
|
432
|
-
|
433
|
-
err(function(){
|
434
|
-
expect('asd').to.not.have.property('foo', 3, 'blah');
|
435
|
-
}, "blah: 'asd' has no property 'foo'");
|
436
|
-
|
437
|
-
err(function(){
|
438
|
-
expect('asd').to.have.property('constructor', Number, 'blah');
|
439
|
-
}, "blah: expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String]");
|
440
|
-
});
|
441
|
-
|
442
|
-
it('deep.property(name, val)', function(){
|
443
|
-
expect({ foo: { bar: 'baz' } })
|
444
|
-
.to.have.deep.property('foo.bar', 'baz');
|
445
|
-
|
446
|
-
err(function(){
|
447
|
-
expect({ foo: { bar: 'baz' } })
|
448
|
-
.to.have.deep.property('foo.bar', 'quux', 'blah');
|
449
|
-
}, "blah: expected { foo: { bar: 'baz' } } to have a deep property 'foo.bar' of 'quux', but got 'baz'");
|
450
|
-
err(function(){
|
451
|
-
expect({ foo: { bar: 'baz' } })
|
452
|
-
.to.not.have.deep.property('foo.bar', 'baz', 'blah');
|
453
|
-
}, "blah: expected { foo: { bar: 'baz' } } to not have a deep property 'foo.bar' of 'baz'");
|
454
|
-
err(function(){
|
455
|
-
expect({ foo: 5 })
|
456
|
-
.to.not.have.deep.property('foo.bar', 'baz', 'blah');
|
457
|
-
}, "blah: { foo: 5 } has no deep property 'foo.bar'");
|
458
|
-
});
|
459
|
-
|
460
|
-
it('ownProperty(name)', function(){
|
461
|
-
expect('test').to.have.ownProperty('length');
|
462
|
-
expect('test').to.haveOwnProperty('length');
|
463
|
-
expect({ length: 12 }).to.have.ownProperty('length');
|
464
|
-
|
465
|
-
err(function(){
|
466
|
-
expect({ length: 12 }).to.not.have.ownProperty('length', 'blah');
|
467
|
-
}, "blah: expected { length: 12 } to not have own property 'length'");
|
468
|
-
});
|
469
|
-
|
470
|
-
it('string()', function(){
|
471
|
-
expect('foobar').to.have.string('bar');
|
472
|
-
expect('foobar').to.have.string('foo');
|
473
|
-
expect('foobar').to.not.have.string('baz');
|
474
|
-
|
475
|
-
err(function(){
|
476
|
-
expect(3).to.have.string('baz');
|
477
|
-
}, "expected 3 to be a string");
|
478
|
-
|
479
|
-
err(function(){
|
480
|
-
expect('foobar').to.have.string('baz', 'blah');
|
481
|
-
}, "blah: expected 'foobar' to contain 'baz'");
|
482
|
-
|
483
|
-
err(function(){
|
484
|
-
expect('foobar').to.not.have.string('bar', 'blah');
|
485
|
-
}, "blah: expected 'foobar' to not contain 'bar'");
|
486
|
-
});
|
487
|
-
|
488
|
-
it('include()', function(){
|
489
|
-
expect(['foo', 'bar']).to.include('foo');
|
490
|
-
expect(['foo', 'bar']).to.include('foo');
|
491
|
-
expect(['foo', 'bar']).to.include('bar');
|
492
|
-
expect([1,2]).to.include(1);
|
493
|
-
expect(['foo', 'bar']).to.not.include('baz');
|
494
|
-
expect(['foo', 'bar']).to.not.include(1);
|
495
|
-
expect({a:1,b:2}).to.include({b:2});
|
496
|
-
expect({a:1,b:2}).to.not.include({b:3});
|
497
|
-
expect({a:1,b:2}).to.include({a:1,b:2});
|
498
|
-
expect({a:1,b:2}).to.not.include({a:1,c:2});
|
499
|
-
|
500
|
-
expect([{a:1},{b:2}]).to.include({a:1});
|
501
|
-
expect([{a:1}]).to.include({a:1});
|
502
|
-
expect([{a:1}]).to.not.include({b:1});
|
503
|
-
|
504
|
-
err(function(){
|
505
|
-
expect(['foo']).to.include('bar', 'blah');
|
506
|
-
}, "blah: expected [ 'foo' ] to include 'bar'");
|
507
|
-
|
508
|
-
err(function(){
|
509
|
-
expect(['bar', 'foo']).to.not.include('foo', 'blah');
|
510
|
-
}, "blah: expected [ 'bar', 'foo' ] to not include 'foo'");
|
511
|
-
|
512
|
-
err(function(){
|
513
|
-
expect({a:1}).to.include({b:2});
|
514
|
-
}, "expected { a: 1 } to have a property 'b'");
|
515
|
-
|
516
|
-
err(function(){
|
517
|
-
expect({a:1,b:2}).to.not.include({b:2});
|
518
|
-
}, "expected { a: 1, b: 2 } to not include { b: 2 }");
|
519
|
-
|
520
|
-
err(function(){
|
521
|
-
expect([{a:1},{b:2}]).to.not.include({b:2});
|
522
|
-
}, "expected [ { a: 1 }, { b: 2 } ] to not include { b: 2 }");
|
523
|
-
});
|
524
|
-
|
525
|
-
it('keys(array)', function(){
|
526
|
-
expect({ foo: 1 }).to.have.keys(['foo']);
|
527
|
-
expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
|
528
|
-
expect({ foo: 1, bar: 2 }).to.have.keys('foo', 'bar');
|
529
|
-
expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
|
530
|
-
expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('bar', 'foo');
|
531
|
-
expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('baz');
|
532
|
-
|
533
|
-
expect({ foo: 1, bar: 2 }).to.contain.keys('foo');
|
534
|
-
expect({ foo: 1, bar: 2 }).to.contain.keys('bar', 'foo');
|
535
|
-
expect({ foo: 1, bar: 2 }).to.contain.keys(['foo']);
|
536
|
-
expect({ foo: 1, bar: 2 }).to.contain.keys(['bar']);
|
537
|
-
expect({ foo: 1, bar: 2 }).to.contain.keys(['bar', 'foo']);
|
538
|
-
|
539
|
-
expect({ foo: 1, bar: 2 }).to.not.have.keys('baz');
|
540
|
-
expect({ foo: 1, bar: 2 }).to.not.have.keys('foo', 'baz');
|
541
|
-
expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz');
|
542
|
-
expect({ foo: 1, bar: 2 }).to.not.contain.keys('foo', 'baz');
|
543
|
-
expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz', 'foo');
|
544
|
-
|
545
|
-
err(function(){
|
546
|
-
expect({ foo: 1 }).to.have.keys();
|
547
|
-
}, "keys required");
|
548
|
-
|
549
|
-
err(function(){
|
550
|
-
expect({ foo: 1 }).to.have.keys([]);
|
551
|
-
}, "keys required");
|
552
|
-
|
553
|
-
err(function(){
|
554
|
-
expect({ foo: 1 }).to.not.have.keys([]);
|
555
|
-
}, "keys required");
|
556
|
-
|
557
|
-
err(function(){
|
558
|
-
expect({ foo: 1 }).to.contain.keys([]);
|
559
|
-
}, "keys required");
|
560
|
-
|
561
|
-
err(function(){
|
562
|
-
expect({ foo: 1 }).to.have.keys(['bar']);
|
563
|
-
}, "expected { foo: 1 } to have key 'bar'");
|
564
|
-
|
565
|
-
err(function(){
|
566
|
-
expect({ foo: 1 }).to.have.keys(['bar', 'baz']);
|
567
|
-
}, "expected { foo: 1 } to have keys 'bar', and 'baz'");
|
568
|
-
|
569
|
-
err(function(){
|
570
|
-
expect({ foo: 1 }).to.have.keys(['foo', 'bar', 'baz']);
|
571
|
-
}, "expected { foo: 1 } to have keys 'foo', 'bar', and 'baz'");
|
572
|
-
|
573
|
-
err(function(){
|
574
|
-
expect({ foo: 1 }).to.not.have.keys(['foo']);
|
575
|
-
}, "expected { foo: 1 } to not have key 'foo'");
|
576
|
-
|
577
|
-
err(function(){
|
578
|
-
expect({ foo: 1 }).to.not.have.keys(['foo']);
|
579
|
-
}, "expected { foo: 1 } to not have key 'foo'");
|
580
|
-
|
581
|
-
err(function(){
|
582
|
-
expect({ foo: 1, bar: 2 }).to.not.have.keys(['foo', 'bar']);
|
583
|
-
}, "expected { foo: 1, bar: 2 } to not have keys 'foo', and 'bar'");
|
584
|
-
|
585
|
-
err(function(){
|
586
|
-
expect({ foo: 1 }).to.not.contain.keys(['foo']);
|
587
|
-
}, "expected { foo: 1 } to not contain key 'foo'");
|
588
|
-
|
589
|
-
err(function(){
|
590
|
-
expect({ foo: 1 }).to.contain.keys('foo', 'bar');
|
591
|
-
}, "expected { foo: 1 } to contain keys 'foo', and 'bar'");
|
592
|
-
});
|
593
|
-
|
594
|
-
it('chaining', function(){
|
595
|
-
var tea = { name: 'chai', extras: ['milk', 'sugar', 'smile'] };
|
596
|
-
expect(tea).to.have.property('extras').with.lengthOf(3);
|
597
|
-
|
598
|
-
err(function(){
|
599
|
-
expect(tea).to.have.property('extras').with.lengthOf(4);
|
600
|
-
}, "expected [ 'milk', 'sugar', 'smile' ] to have a length of 4 but got 3");
|
601
|
-
|
602
|
-
expect(tea).to.be.a('object').and.have.property('name', 'chai');
|
603
|
-
|
604
|
-
var badFn = function () { throw new Error('testing'); };
|
605
|
-
|
606
|
-
expect(badFn).to.throw(Error).with.property('message', 'testing');
|
607
|
-
});
|
608
|
-
|
609
|
-
it('throw', function () {
|
610
|
-
// See GH-45: some poorly-constructed custom errors don't have useful names
|
611
|
-
// on either their constructor or their constructor prototype, but instead
|
612
|
-
// only set the name inside the constructor itself.
|
613
|
-
var PoorlyConstructedError = function () {
|
614
|
-
this.name = 'PoorlyConstructedError';
|
615
|
-
};
|
616
|
-
PoorlyConstructedError.prototype = Object.create(Error.prototype);
|
617
|
-
|
618
|
-
function CustomError(message) {
|
619
|
-
this.name = 'CustomError';
|
620
|
-
this.message = message;
|
621
|
-
}
|
622
|
-
CustomError.prototype = Error.prototype;
|
623
|
-
|
624
|
-
var specificError = new RangeError('boo');
|
625
|
-
|
626
|
-
var goodFn = function () { 1==1; }
|
627
|
-
, badFn = function () { throw new Error('testing'); }
|
628
|
-
, refErrFn = function () { throw new ReferenceError('hello'); }
|
629
|
-
, ickyErrFn = function () { throw new PoorlyConstructedError(); }
|
630
|
-
, specificErrFn = function () { throw specificError; }
|
631
|
-
, customErrFn = function() { throw new CustomError('foo'); };
|
632
|
-
|
633
|
-
expect(goodFn).to.not.throw();
|
634
|
-
expect(goodFn).to.not.throw(Error);
|
635
|
-
expect(goodFn).to.not.throw(specificError);
|
636
|
-
expect(badFn).to.throw();
|
637
|
-
expect(badFn).to.throw(Error);
|
638
|
-
expect(badFn).to.not.throw(ReferenceError);
|
639
|
-
expect(badFn).to.not.throw(specificError);
|
640
|
-
expect(refErrFn).to.throw();
|
641
|
-
expect(refErrFn).to.throw(ReferenceError);
|
642
|
-
expect(refErrFn).to.throw(Error);
|
643
|
-
expect(refErrFn).to.not.throw(TypeError);
|
644
|
-
expect(refErrFn).to.not.throw(specificError);
|
645
|
-
expect(ickyErrFn).to.throw();
|
646
|
-
expect(ickyErrFn).to.throw(PoorlyConstructedError);
|
647
|
-
expect(ickyErrFn).to.throw(Error);
|
648
|
-
expect(ickyErrFn).to.not.throw(specificError);
|
649
|
-
expect(specificErrFn).to.throw(specificError);
|
650
|
-
|
651
|
-
expect(badFn).to.throw(/testing/);
|
652
|
-
expect(badFn).to.not.throw(/hello/);
|
653
|
-
expect(badFn).to.throw('testing');
|
654
|
-
expect(badFn).to.not.throw('hello');
|
655
|
-
|
656
|
-
expect(badFn).to.throw(Error, /testing/);
|
657
|
-
expect(badFn).to.throw(Error, 'testing');
|
658
|
-
|
659
|
-
err(function(){
|
660
|
-
expect(goodFn).to.throw();
|
661
|
-
}, "expected [Function] to throw an error");
|
662
|
-
|
663
|
-
err(function(){
|
664
|
-
expect(goodFn).to.throw(ReferenceError);
|
665
|
-
}, "expected [Function] to throw ReferenceError");
|
666
|
-
|
667
|
-
err(function(){
|
668
|
-
expect(goodFn).to.throw(specificError);
|
669
|
-
}, "expected [Function] to throw 'RangeError: boo'");
|
670
|
-
|
671
|
-
err(function(){
|
672
|
-
expect(badFn).to.not.throw();
|
673
|
-
}, "expected [Function] to not throw an error but 'Error: testing' was thrown");
|
674
|
-
|
675
|
-
err(function(){
|
676
|
-
expect(badFn).to.throw(ReferenceError);
|
677
|
-
}, "expected [Function] to throw 'ReferenceError' but 'Error: testing' was thrown");
|
678
|
-
|
679
|
-
err(function(){
|
680
|
-
expect(badFn).to.throw(specificError);
|
681
|
-
}, "expected [Function] to throw 'RangeError: boo' but 'Error: testing' was thrown");
|
682
|
-
|
683
|
-
err(function(){
|
684
|
-
expect(badFn).to.not.throw(Error);
|
685
|
-
}, "expected [Function] to not throw 'Error' but 'Error: testing' was thrown");
|
686
|
-
|
687
|
-
err(function(){
|
688
|
-
expect(refErrFn).to.not.throw(ReferenceError);
|
689
|
-
}, "expected [Function] to not throw 'ReferenceError' but 'ReferenceError: hello' was thrown");
|
690
|
-
|
691
|
-
err(function(){
|
692
|
-
expect(badFn).to.throw(PoorlyConstructedError);
|
693
|
-
}, "expected [Function] to throw 'PoorlyConstructedError' but 'Error: testing' was thrown");
|
694
|
-
|
695
|
-
err(function(){
|
696
|
-
expect(ickyErrFn).to.not.throw(PoorlyConstructedError);
|
697
|
-
}, /^(expected \[Function\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
698
|
-
|
699
|
-
err(function(){
|
700
|
-
expect(ickyErrFn).to.throw(ReferenceError);
|
701
|
-
}, /^(expected \[Function\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
702
|
-
|
703
|
-
err(function(){
|
704
|
-
expect(specificErrFn).to.throw(new ReferenceError('eek'));
|
705
|
-
}, "expected [Function] to throw 'ReferenceError: eek' but 'RangeError: boo' was thrown");
|
706
|
-
|
707
|
-
err(function(){
|
708
|
-
expect(specificErrFn).to.not.throw(specificError);
|
709
|
-
}, "expected [Function] to not throw 'RangeError: boo'");
|
710
|
-
|
711
|
-
err(function (){
|
712
|
-
expect(badFn).to.not.throw(/testing/);
|
713
|
-
}, "expected [Function] to throw error not matching /testing/");
|
714
|
-
|
715
|
-
err(function () {
|
716
|
-
expect(badFn).to.throw(/hello/);
|
717
|
-
}, "expected [Function] to throw error matching /hello/ but got 'testing'");
|
718
|
-
|
719
|
-
err(function () {
|
720
|
-
expect(badFn).to.throw(Error, /hello/, 'blah');
|
721
|
-
}, "blah: expected [Function] to throw error matching /hello/ but got 'testing'");
|
722
|
-
|
723
|
-
err(function () {
|
724
|
-
expect(badFn).to.throw(Error, 'hello', 'blah');
|
725
|
-
}, "blah: expected [Function] to throw error including 'hello' but got 'testing'");
|
726
|
-
|
727
|
-
err(function () {
|
728
|
-
(customErrFn).should.not.throw();
|
729
|
-
}, "expected [Function] to not throw an error but 'CustomError: foo' was thrown");
|
730
|
-
});
|
731
|
-
|
732
|
-
it('respondTo', function(){
|
733
|
-
function Foo(){};
|
734
|
-
Foo.prototype.bar = function(){};
|
735
|
-
Foo.func = function() {};
|
736
|
-
|
737
|
-
var bar = {};
|
738
|
-
bar.foo = function(){};
|
739
|
-
|
740
|
-
expect(Foo).to.respondTo('bar');
|
741
|
-
expect(Foo).to.not.respondTo('foo');
|
742
|
-
expect(Foo).itself.to.respondTo('func');
|
743
|
-
expect(Foo).itself.not.to.respondTo('bar');
|
744
|
-
|
745
|
-
expect(bar).to.respondTo('foo');
|
746
|
-
|
747
|
-
err(function(){
|
748
|
-
expect(Foo).to.respondTo('baz', 'constructor');
|
749
|
-
}, /^(constructor: expected)(.*)(\[Function: Foo\])(.*)(to respond to \'baz\')$/);
|
750
|
-
|
751
|
-
err(function(){
|
752
|
-
expect(bar).to.respondTo('baz', 'object');
|
753
|
-
}, /^(object: expected)(.*)(\{ foo: \[Function\] \}|\{ Object \()(.*)(to respond to \'baz\')$/);
|
754
|
-
});
|
755
|
-
|
756
|
-
it('satisfy', function(){
|
757
|
-
var matcher = function (num) {
|
758
|
-
return num === 1;
|
759
|
-
};
|
760
|
-
|
761
|
-
expect(1).to.satisfy(matcher);
|
762
|
-
|
763
|
-
err(function(){
|
764
|
-
expect(2).to.satisfy(matcher, 'blah');
|
765
|
-
}, "blah: expected 2 to satisfy [Function]");
|
766
|
-
});
|
767
|
-
|
768
|
-
it('closeTo', function(){
|
769
|
-
expect(1.5).to.be.closeTo(1.0, 0.5);
|
770
|
-
expect(10).to.be.closeTo(20, 20);
|
771
|
-
expect(-10).to.be.closeTo(20, 30);
|
772
|
-
|
773
|
-
err(function(){
|
774
|
-
expect(2).to.be.closeTo(1.0, 0.5, 'blah');
|
775
|
-
}, "blah: expected 2 to be close to 1 +/- 0.5");
|
776
|
-
|
777
|
-
err(function(){
|
778
|
-
expect(-10).to.be.closeTo(20, 29, 'blah');
|
779
|
-
}, "blah: expected -10 to be close to 20 +/- 29");
|
780
|
-
});
|
781
|
-
|
782
|
-
it('include.members', function() {
|
783
|
-
expect([1, 2, 3]).to.include.members([]);
|
784
|
-
expect([1, 2, 3]).to.include.members([3, 2]);
|
785
|
-
expect([1, 2, 3]).to.not.include.members([8, 4]);
|
786
|
-
expect([1, 2, 3]).to.not.include.members([1, 2, 3, 4]);
|
787
|
-
});
|
788
|
-
|
789
|
-
it('same.members', function() {
|
790
|
-
expect([5, 4]).to.have.same.members([4, 5]);
|
791
|
-
expect([5, 4]).to.have.same.members([5, 4]);
|
792
|
-
expect([5, 4]).to.not.have.same.members([]);
|
793
|
-
expect([5, 4]).to.not.have.same.members([6, 3]);
|
794
|
-
expect([5, 4]).to.not.have.same.members([5, 4, 2]);
|
795
|
-
});
|
796
|
-
|
797
|
-
it('members', function() {
|
798
|
-
expect([5, 4]).members([4, 5]);
|
799
|
-
expect([5, 4]).members([5, 4]);
|
800
|
-
expect([5, 4]).not.members([]);
|
801
|
-
expect([5, 4]).not.members([6, 3]);
|
802
|
-
expect([5, 4]).not.members([5, 4, 2]);
|
803
|
-
expect([{ id: 1 }]).not.members([{ id: 1 }]);
|
804
|
-
});
|
805
|
-
|
806
|
-
it('deep.members', function() {
|
807
|
-
expect([{ id: 1 }]).deep.members([{ id: 1 }]);
|
808
|
-
expect([{ id: 2 }]).not.deep.members([{ id: 1 }]);
|
809
|
-
err(function(){
|
810
|
-
expect([{ id: 1 }]).deep.members([{ id: 2 }])
|
811
|
-
}, "expected [ { id: 1 } ] to have the same members as [ { id: 2 } ]");
|
812
|
-
});
|
813
|
-
|
814
|
-
});
|