ende 0.5.20 → 0.5.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +1 -1
- data/components/indefinido/indemma/master/.gitignore +17 -0
- data/components/indefinido/indemma/master/.ruby-gemset +1 -0
- data/components/indefinido/indemma/master/.ruby-version +1 -0
- data/components/indefinido/indemma/master/Gemfile +12 -0
- data/components/indefinido/indemma/master/Guardfile +39 -0
- data/components/indefinido/indemma/master/History.md +0 -0
- data/components/indefinido/indemma/master/Readme.md +445 -0
- data/components/indefinido/indemma/master/build/development.js +26123 -0
- data/components/indefinido/indemma/master/build/release.js +16741 -0
- data/components/indefinido/indemma/master/build/test.js +26123 -0
- data/components/indefinido/indemma/master/component.json +1 -1
- data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/component.json +18 -0
- data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/index.js +110 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.gitignore +22 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.mailmap +1 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.npmignore +14 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.travis.yml +14 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/CONTRIBUTING.md +173 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/History.md +895 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/Makefile +93 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/README.md +99 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/ReleaseNotes.md +482 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/bower.json +27 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/chai.js +4782 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/component.json +50 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/index.js +1 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.conf.js +28 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.sauce.js +41 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/assertion.js +130 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/config.js +50 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/core/assertions.js +1314 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/assert.js +1056 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/expect.js +12 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/should.js +78 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addChainableMethod.js +111 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addMethod.js +43 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addProperty.js +40 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/flag.js +32 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getActual.js +18 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getMessage.js +49 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getName.js +20 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getPathValue.js +102 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getProperties.js +35 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/index.js +114 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/inspect.js +320 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/objDisplay.js +49 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteChainableMethod.js +53 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteMethod.js +51 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteProperty.js +54 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/test.js +26 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/transferFlags.js +44 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/type.js +45 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai.js +87 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/package.json +42 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/sauce.browsers.js +128 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_block.sh +7 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_setup.sh +53 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/assert.js +638 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/auth/.gitkeep +0 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/index.js +22 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/karma.js +22 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/configuration.js +133 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/errors.js +14 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/message.js +47 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/expect.js +814 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/globalShould.js +15 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/plugins.js +24 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/should.js +744 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/utilities.js +309 -0
- data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/component.json +20 -0
- data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/lib/eql.js +257 -0
- data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/component.json +18 -0
- data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/lib/type.js +142 -0
- data/components/indefinido/indemma/master/components/component/bind/1.0.0/component.json +14 -0
- data/components/indefinido/indemma/master/components/component/bind/1.0.0/index.js +23 -0
- data/components/indefinido/indemma/master/components/component/jquery/1.0.0/component.json +10 -0
- data/components/indefinido/indemma/master/components/component/jquery/1.0.0/index.js +10308 -0
- data/components/indefinido/indemma/master/components/component/type/1.0.0/component.json +20 -0
- data/components/indefinido/indemma/master/components/component/type/1.0.0/index.js +32 -0
- data/components/indefinido/indemma/master/components/indefinido/advisable/master/component.json +21 -0
- data/components/indefinido/indemma/master/components/indefinido/advisable/master/index.js +1 -0
- data/components/indefinido/indemma/master/components/indefinido/advisable/master/lib/advisable.js +60 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/component.json +39 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/index.js +1 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/adapters/rivets.js +40 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/notifierable.js +145 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +147 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/lookup.js +38 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/keypath_observer.js +38 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/observation.js +45 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/selection.js +57 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/self_observer.js +38 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable.js +97 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/platform.js +12 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/observe-js/observe.js +1631 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors-legacy.js +92 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors.js +248 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/array.indexOf.js +8 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/object.create.js +77 -0
- data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/component.json +25 -0
- data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/dist/assimilate.js +127 -0
- data/components/indefinido/indemma/master/karma.conf.js +75 -0
- data/components/indefinido/indemma/master/lib/record/associable.js +4 -2
- data/components/indefinido/indemma/master/lib/record/dirtyable.js +1 -1
- data/components/indefinido/indemma/master/package.json +9 -0
- data/components/indefinido/indemma/master/spec/record/associable_spec.js +211 -0
- data/components/indefinido/indemma/master/spec/record/dirtyable_spec.js +57 -0
- data/components/indefinido/indemma/master/spec/record/maid_spec.js +40 -0
- data/components/indefinido/indemma/master/spec/record/persistable_spec.js +46 -0
- data/components/indefinido/indemma/master/spec/record/queryable_spec.js +39 -0
- data/components/indefinido/indemma/master/spec/record/resource_spec.js +93 -0
- data/components/indefinido/indemma/master/spec/record/rest_spec.js +32 -0
- data/components/indefinido/indemma/master/spec/record/restfulable_spec.js +346 -0
- data/components/indefinido/indemma/master/spec/record/scopable_spec.js +242 -0
- data/components/indefinido/indemma/master/spec/record/storable_spec.js +44 -0
- data/components/indefinido/indemma/master/spec/record/translationable.js +28 -0
- data/components/indefinido/indemma/master/spec/record/validatable_spec.js +142 -0
- data/components/indefinido/indemma/master/spec/record/validations/associated_spec.js +43 -0
- data/components/indefinido/indemma/master/spec/record/validations/confirmation_spec.js +36 -0
- data/components/indefinido/indemma/master/spec/record/validations/cpf_spec.js +34 -0
- data/components/indefinido/indemma/master/spec/record/validations/presence_spec.js +28 -0
- data/components/indefinido/indemma/master/spec/record/validations/remote_spec.js +87 -0
- data/components/indefinido/indemma/master/spec/record/validations/type_spec.js +48 -0
- data/components/indefinido/indemma/master/spec/record_spec.js +49 -0
- data/components/indefinido/indemma/master/spec/spec_helper.js +15 -0
- data/components/indefinido/indemma/master/spec/support/value_objects/phone.js +45 -0
- data/components/indefinido/indemma/master/src/lib/extensions/rivets.coffee +17 -0
- data/components/indefinido/indemma/master/src/lib/record/associable.coffee +419 -0
- data/components/indefinido/indemma/master/src/lib/record/dirtyable.coffee +47 -0
- data/components/indefinido/indemma/master/src/lib/record/errors.coffee +20 -0
- data/components/indefinido/indemma/master/src/lib/record/maid.coffee +16 -0
- data/components/indefinido/indemma/master/src/lib/record/persistable.coffee +34 -0
- data/components/indefinido/indemma/master/src/lib/record/queryable.coffee +29 -0
- data/components/indefinido/indemma/master/src/lib/record/resource.coffee +107 -0
- data/components/indefinido/indemma/master/src/lib/record/rest.coffee +34 -0
- data/components/indefinido/indemma/master/src/lib/record/restfulable.coffee +487 -0
- data/components/indefinido/indemma/master/src/lib/record/scopable.coffee +279 -0
- data/components/indefinido/indemma/master/src/lib/record/storable.coffee +49 -0
- data/components/indefinido/indemma/master/src/lib/record/translationable.coffee +18 -0
- data/components/indefinido/indemma/master/src/lib/record/validatable.coffee +241 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/associated.coffee +34 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/confirmation.coffee +17 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/cpf.coffee +57 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/presence.coffee +16 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/remote.coffee +61 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/type.coffee +31 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/validatorable.coffee +5 -0
- data/components/indefinido/indemma/master/src/lib/record.coffee +143 -0
- data/components/indefinido/indemma/master/src/spec/record/associable_spec.coffee +205 -0
- data/components/indefinido/indemma/master/src/spec/record/dirtyable_spec.coffee +47 -0
- data/components/indefinido/indemma/master/src/spec/record/maid_spec.coffee +34 -0
- data/components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee +39 -0
- data/components/indefinido/indemma/master/src/spec/record/queryable_spec.coffee +33 -0
- data/components/indefinido/indemma/master/src/spec/record/resource_spec.coffee +69 -0
- data/components/indefinido/indemma/master/src/spec/record/rest_spec.coffee +22 -0
- data/components/indefinido/indemma/master/src/spec/record/restfulable_spec.coffee +257 -0
- data/components/indefinido/indemma/master/src/spec/record/scopable_spec.coffee +227 -0
- data/components/indefinido/indemma/master/src/spec/record/storable_spec.coffee +39 -0
- data/components/indefinido/indemma/master/src/spec/record/translationable.coffee +19 -0
- data/components/indefinido/indemma/master/src/spec/record/validatable_spec.coffee +127 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/associated_spec.coffee +35 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee +25 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/cpf_spec.coffee +27 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/presence_spec.coffee +24 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/remote_spec.coffee +74 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee +33 -0
- data/components/indefinido/indemma/master/src/spec/record_spec.coffee +29 -0
- data/components/indefinido/indemma/master/src/spec/spec_helper.coffee +11 -0
- data/components/indefinido/indemma/master/src/spec/support/value_objects/phone.coffee +30 -0
- data/components/indefinido/indemma/master/vendor/object/mixin.js +196 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/assert.js +199 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/behavior.js +334 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/call.js +205 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/collection.js +155 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/match.js +245 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/mock.js +451 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/sandbox.js +144 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/spy.js +413 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/stub.js +161 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/test.js +77 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/test_case.js +99 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/event.js +94 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server.js +212 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server_with_clock.js +83 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_timers.js +405 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xdomain_request.js +206 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xml_http_request.js +575 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/timers_ie.js +31 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/xdr_ie.js +14 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/xhr_ie.js +19 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon.js +383 -0
- data/lib/assets/javascripts/value_objects/phone.js.coffee +3 -1
- data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +5 -5
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.css +4 -4
- data/vendor/assets/components/ende_build.js +7974 -7889
- metadata +191 -5
- data/vendor/assets/component/build.css +0 -112
- data/vendor/assets/components/build.css +0 -112
- data/vendor/assets/components/indemma_with_none.js +0 -30553
@@ -0,0 +1,744 @@
|
|
1
|
+
describe('should', function() {
|
2
|
+
var should = chai.Should();
|
3
|
+
|
4
|
+
it('assertion', function(){
|
5
|
+
'test'.should.be.a('string');
|
6
|
+
should.equal('foo', 'foo');
|
7
|
+
should.not.equal('foo', 'bar');
|
8
|
+
});
|
9
|
+
|
10
|
+
it('root exist', function () {
|
11
|
+
var foo = 'foo'
|
12
|
+
, bar = undefined;
|
13
|
+
should.exist(foo);
|
14
|
+
should.not.exist(bar);
|
15
|
+
|
16
|
+
err(function () {
|
17
|
+
should.exist(bar, 'blah');
|
18
|
+
}, "blah: expected undefined to exist");
|
19
|
+
|
20
|
+
err(function () {
|
21
|
+
should.not.exist(foo, 'blah');
|
22
|
+
}, "blah: expected 'foo' to not exist")
|
23
|
+
});
|
24
|
+
|
25
|
+
it('root equal', function () {
|
26
|
+
var value1 = 'value'
|
27
|
+
, value2 = 'value'
|
28
|
+
, foo = 'foo';
|
29
|
+
should.equal(value1, value2);
|
30
|
+
should.not.equal(value1, foo);
|
31
|
+
|
32
|
+
err(function () {
|
33
|
+
should.equal(value1, foo, 'blah');
|
34
|
+
}, "blah: expected 'value' to equal 'foo'");
|
35
|
+
|
36
|
+
err(function () {
|
37
|
+
should.not.equal(value1, value2, 'blah');
|
38
|
+
}, "blah: expected 'value' to not equal 'value'")
|
39
|
+
});
|
40
|
+
|
41
|
+
it('root Throw', function () {
|
42
|
+
should.Throw(function() { throw new Error('error!') }, Error, 'error!');
|
43
|
+
should.not.Throw(function () { });
|
44
|
+
|
45
|
+
err(function () {
|
46
|
+
should.Throw(function () { throw new Error('error!') }, Error, 'needed user!', 'blah');
|
47
|
+
}, "blah: expected [Function] to throw error including 'needed user!' but got 'error!'");
|
48
|
+
|
49
|
+
err(function () {
|
50
|
+
should.not.Throw(function () { throw new Error('error!') }, Error, 'error!', 'blah');
|
51
|
+
}, "blah: expected [Function] to not throw 'Error' but 'Error: error!' was thrown");
|
52
|
+
});
|
53
|
+
|
54
|
+
it('true', function(){
|
55
|
+
(true).should.be.true;
|
56
|
+
false.should.not.be.true;
|
57
|
+
(1).should.not.be.true;false
|
58
|
+
false.should.have.been.false;
|
59
|
+
|
60
|
+
err(function(){
|
61
|
+
'test'.should.be.true;
|
62
|
+
}, "expected 'test' to be true")
|
63
|
+
});
|
64
|
+
|
65
|
+
it('ok', function(){
|
66
|
+
true.should.be.ok;
|
67
|
+
false.should.not.be.ok;
|
68
|
+
(1).should.be.ok;
|
69
|
+
(0).should.not.be.ok;
|
70
|
+
|
71
|
+
err(function(){
|
72
|
+
''.should.be.ok;
|
73
|
+
}, "expected '' to be truthy");
|
74
|
+
|
75
|
+
err(function(){
|
76
|
+
'test'.should.not.be.ok;
|
77
|
+
}, "expected 'test' to be falsy");
|
78
|
+
});
|
79
|
+
|
80
|
+
it('false', function(){
|
81
|
+
false.should.be.false;
|
82
|
+
true.should.not.be.false;
|
83
|
+
(0).should.not.be.false;
|
84
|
+
|
85
|
+
err(function(){
|
86
|
+
''.should.be.false;
|
87
|
+
}, "expected '' to be false")
|
88
|
+
});
|
89
|
+
|
90
|
+
it('null', function(){
|
91
|
+
(0).should.not.be.null;
|
92
|
+
|
93
|
+
err(function(){
|
94
|
+
''.should.be.null;
|
95
|
+
}, "expected '' to be null")
|
96
|
+
});
|
97
|
+
|
98
|
+
it('undefined', function(){
|
99
|
+
(0).should.not.be.undefined;
|
100
|
+
|
101
|
+
err(function(){
|
102
|
+
''.should.be.undefined;
|
103
|
+
}, "expected '' to be undefined")
|
104
|
+
});
|
105
|
+
|
106
|
+
it('arguments', function(){
|
107
|
+
var args = (function(){ return arguments; })(1,2,3);
|
108
|
+
args.should.be.arguments;
|
109
|
+
[].should.not.be.arguments;
|
110
|
+
});
|
111
|
+
|
112
|
+
it('.equal()', function(){
|
113
|
+
var foo;
|
114
|
+
should.equal(undefined, foo);
|
115
|
+
});
|
116
|
+
|
117
|
+
it('typeof', function(){
|
118
|
+
'test'.should.be.a('string');
|
119
|
+
|
120
|
+
err(function(){
|
121
|
+
'test'.should.not.be.a('string');
|
122
|
+
}, "expected 'test' not to be a string");
|
123
|
+
|
124
|
+
(5).should.be.a('number');
|
125
|
+
(new Number(1)).should.be.a('number');
|
126
|
+
Number(1).should.be.a('number');
|
127
|
+
(true).should.be.a('boolean');
|
128
|
+
(new Array()).should.be.a('array');
|
129
|
+
(new Object()).should.be.a('object');
|
130
|
+
({}).should.be.a('object');
|
131
|
+
([]).should.be.a('array');
|
132
|
+
(function() {}).should.be.a('function');
|
133
|
+
|
134
|
+
(5).should.be.a('number');
|
135
|
+
|
136
|
+
err(function(){
|
137
|
+
(5).should.not.be.a('number');
|
138
|
+
}, "expected 5 not to be a number");
|
139
|
+
});
|
140
|
+
|
141
|
+
it('instanceof', function(){
|
142
|
+
function Foo(){}
|
143
|
+
new Foo().should.be.an.instanceof(Foo);
|
144
|
+
|
145
|
+
err(function(){
|
146
|
+
(3).should.an.instanceof(Foo, 'blah');
|
147
|
+
}, "blah: expected 3 to be an instance of Foo");
|
148
|
+
});
|
149
|
+
|
150
|
+
it('within(start, finish)', function(){
|
151
|
+
(5).should.be.within(5, 10);
|
152
|
+
(5).should.be.within(3,6);
|
153
|
+
(5).should.be.within(3,5);
|
154
|
+
(5).should.not.be.within(1,3);
|
155
|
+
|
156
|
+
err(function(){
|
157
|
+
(5).should.not.be.within(4,6, 'blah');
|
158
|
+
}, "blah: expected 5 to not be within 4..6");
|
159
|
+
|
160
|
+
err(function(){
|
161
|
+
(10).should.be.within(50,100, 'blah');
|
162
|
+
}, "blah: expected 10 to be within 50..100");
|
163
|
+
|
164
|
+
err(function(){
|
165
|
+
({ foo: 1 }).should.have.length.within(50,100, 'blah');
|
166
|
+
}, "blah: expected { foo: 1 } to have a property 'length'");
|
167
|
+
});
|
168
|
+
|
169
|
+
it('above(n)', function(){
|
170
|
+
(5).should.be.above(2);
|
171
|
+
(5).should.be.greaterThan(2);
|
172
|
+
(5).should.not.be.above(5);
|
173
|
+
(5).should.not.be.above(6);
|
174
|
+
|
175
|
+
err(function(){
|
176
|
+
(5).should.be.above(6, 'blah');
|
177
|
+
}, "blah: expected 5 to be above 6");
|
178
|
+
|
179
|
+
err(function(){
|
180
|
+
(10).should.not.be.above(6, 'blah');
|
181
|
+
}, "blah: expected 10 to be at most 6");
|
182
|
+
|
183
|
+
err(function(){
|
184
|
+
({foo: 1}).should.have.length.above(3, 'blah');
|
185
|
+
}, "blah: expected { foo: 1 } to have a property 'length'");
|
186
|
+
});
|
187
|
+
|
188
|
+
it('least(n)', function(){
|
189
|
+
(5).should.be.at.least(5);
|
190
|
+
(5).should.not.be.at.least(6);
|
191
|
+
|
192
|
+
err(function(){
|
193
|
+
(5).should.be.at.least(6, 'blah');
|
194
|
+
}, "blah: expected 5 to be at least 6");
|
195
|
+
|
196
|
+
err(function(){
|
197
|
+
(10).should.not.be.at.least(6, 'blah');
|
198
|
+
}, "blah: expected 10 to be below 6");
|
199
|
+
|
200
|
+
err(function(){
|
201
|
+
({foo: 1}).should.have.length.of.at.least(3, 'blah');
|
202
|
+
}, "blah: expected { foo: 1 } to have a property 'length'");
|
203
|
+
});
|
204
|
+
|
205
|
+
it('below(n)', function(){
|
206
|
+
(2).should.be.below(5);
|
207
|
+
(2).should.be.lessThan(5);
|
208
|
+
(2).should.not.be.below(2);
|
209
|
+
(2).should.not.be.below(1);
|
210
|
+
|
211
|
+
err(function(){
|
212
|
+
(6).should.be.below(5, 'blah');
|
213
|
+
}, "blah: expected 6 to be below 5");
|
214
|
+
|
215
|
+
err(function(){
|
216
|
+
(6).should.not.be.below(10, 'blah');
|
217
|
+
}, "blah: expected 6 to be at least 10");
|
218
|
+
|
219
|
+
err(function(){
|
220
|
+
({foo: 1}).should.have.length.below(3, 'blah');
|
221
|
+
}, "blah: expected { foo: 1 } to have a property 'length'");
|
222
|
+
});
|
223
|
+
|
224
|
+
it('most(n)', function(){
|
225
|
+
(2).should.be.at.most(2);
|
226
|
+
(2).should.not.be.at.most(1);
|
227
|
+
|
228
|
+
err(function(){
|
229
|
+
(6).should.be.at.most(5, 'blah');
|
230
|
+
}, "blah: expected 6 to be at most 5");
|
231
|
+
|
232
|
+
err(function(){
|
233
|
+
(6).should.not.be.at.most(10, 'blah');
|
234
|
+
}, "blah: expected 6 to be above 10");
|
235
|
+
|
236
|
+
err(function(){
|
237
|
+
({foo: 1}).should.have.length.of.at.most(3, 'blah');
|
238
|
+
}, "blah: expected { foo: 1 } to have a property 'length'");
|
239
|
+
});
|
240
|
+
|
241
|
+
it('match(regexp)', function(){
|
242
|
+
'foobar'.should.match(/^foo/)
|
243
|
+
'foobar'.should.not.match(/^bar/)
|
244
|
+
|
245
|
+
err(function(){
|
246
|
+
'foobar'.should.match(/^bar/i, 'blah')
|
247
|
+
}, "blah: expected 'foobar' to match /^bar/i");
|
248
|
+
|
249
|
+
err(function(){
|
250
|
+
'foobar'.should.not.match(/^foo/i, 'blah')
|
251
|
+
}, "blah: expected 'foobar' not to match /^foo/i");
|
252
|
+
});
|
253
|
+
|
254
|
+
it('length(n)', function(){
|
255
|
+
'test'.should.have.length(4);
|
256
|
+
'test'.should.not.have.length(3);
|
257
|
+
[1,2,3].should.have.length(3);
|
258
|
+
|
259
|
+
err(function(){
|
260
|
+
(4).should.have.length(3, 'blah');
|
261
|
+
}, 'blah: expected 4 to have a property \'length\'');
|
262
|
+
|
263
|
+
err(function(){
|
264
|
+
'asd'.should.not.have.length(3, 'blah');
|
265
|
+
}, "blah: expected 'asd' to not have a length of 3");
|
266
|
+
});
|
267
|
+
|
268
|
+
it('eql(val)', function(){
|
269
|
+
var a = new Date(1, 2, 3)
|
270
|
+
, b = new Date(4, 5, 6);
|
271
|
+
|
272
|
+
a.should.eql(a);
|
273
|
+
a.should.not.eql(b);
|
274
|
+
a.should.not.eql({});
|
275
|
+
'test'.should.eql('test');
|
276
|
+
({ foo: 'bar' }).should.eql({ foo: 'bar' });
|
277
|
+
/a/.should.eql(/a/);
|
278
|
+
/a/.should.not.eql(/b/);
|
279
|
+
/a/.should.not.eql({});
|
280
|
+
/a/g.should.eql(/a/g);
|
281
|
+
/a/g.should.not.eql(/b/g);
|
282
|
+
/a/i.should.eql(/a/i);
|
283
|
+
/a/i.should.not.eql(/b/i);
|
284
|
+
/a/m.should.eql(/a/m);
|
285
|
+
/a/m.should.not.eql(/b/m);
|
286
|
+
(1).should.eql(1);
|
287
|
+
'4'.should.not.eql(4);
|
288
|
+
|
289
|
+
err(function(){
|
290
|
+
(4).should.eql(3, 'blah');
|
291
|
+
}, 'blah: expected 4 to deeply equal 3');
|
292
|
+
});
|
293
|
+
|
294
|
+
it('equal(val)', function(){
|
295
|
+
'test'.should.equal('test');
|
296
|
+
(1).should.equal(1);
|
297
|
+
|
298
|
+
err(function(){
|
299
|
+
(4).should.equal(3, 'blah');
|
300
|
+
}, 'blah: expected 4 to equal 3');
|
301
|
+
|
302
|
+
err(function(){
|
303
|
+
'4'.should.equal(4, 'blah');
|
304
|
+
}, "blah: expected '4' to equal 4");
|
305
|
+
});
|
306
|
+
|
307
|
+
it('empty', function(){
|
308
|
+
function FakeArgs() {};
|
309
|
+
FakeArgs.prototype.length = 0;
|
310
|
+
|
311
|
+
''.should.be.empty;
|
312
|
+
'foo'.should.not.be.empty;
|
313
|
+
([]).should.be.empty;
|
314
|
+
(['foo']).should.not.be.empty;
|
315
|
+
(new FakeArgs).should.be.empty;
|
316
|
+
({arguments: 0}).should.not.be.empty;
|
317
|
+
({}).should.be.empty;
|
318
|
+
({foo: 'bar'}).should.not.be.empty;
|
319
|
+
|
320
|
+
err(function(){
|
321
|
+
''.should.not.be.empty;
|
322
|
+
}, "expected \'\' not to be empty");
|
323
|
+
|
324
|
+
err(function(){
|
325
|
+
'foo'.should.be.empty;
|
326
|
+
}, "expected \'foo\' to be empty");
|
327
|
+
|
328
|
+
err(function(){
|
329
|
+
([]).should.not.be.empty;
|
330
|
+
}, "expected [] not to be empty");
|
331
|
+
|
332
|
+
err(function(){
|
333
|
+
(['foo']).should.be.empty;
|
334
|
+
}, "expected [ \'foo\' ] to be empty");
|
335
|
+
|
336
|
+
err(function(){
|
337
|
+
(new FakeArgs).should.not.be.empty;
|
338
|
+
}, "expected { length: 0 } not to be empty");
|
339
|
+
|
340
|
+
err(function(){
|
341
|
+
({arguments: 0}).should.be.empty;
|
342
|
+
}, "expected { arguments: 0 } to be empty");
|
343
|
+
|
344
|
+
err(function(){
|
345
|
+
({}).should.not.be.empty;
|
346
|
+
}, "expected {} not to be empty");
|
347
|
+
|
348
|
+
err(function(){
|
349
|
+
({foo: 'bar'}).should.be.empty;
|
350
|
+
}, "expected { foo: \'bar\' } to be empty");
|
351
|
+
});
|
352
|
+
|
353
|
+
it('property(name)', function(){
|
354
|
+
'test'.should.have.property('length');
|
355
|
+
(4).should.not.have.property('length');
|
356
|
+
|
357
|
+
err(function(){
|
358
|
+
'asd'.should.have.property('foo');
|
359
|
+
}, "expected 'asd' to have a property 'foo'");
|
360
|
+
});
|
361
|
+
|
362
|
+
it('property(name, val)', function(){
|
363
|
+
'test'.should.have.property('length', 4);
|
364
|
+
'asd'.should.have.property('constructor', String);
|
365
|
+
|
366
|
+
err(function(){
|
367
|
+
'asd'.should.have.property('length', 4, 'blah');
|
368
|
+
}, "blah: expected 'asd' to have a property 'length' of 4, but got 3");
|
369
|
+
|
370
|
+
err(function(){
|
371
|
+
'asd'.should.not.have.property('length', 3, 'blah');
|
372
|
+
}, "blah: expected 'asd' to not have a property 'length' of 3");
|
373
|
+
|
374
|
+
err(function(){
|
375
|
+
'asd'.should.not.have.property('foo', 3, 'blah');
|
376
|
+
}, "blah: 'asd' has no property 'foo'");
|
377
|
+
|
378
|
+
err(function(){
|
379
|
+
'asd'.should.have.property('constructor', Number, 'blah');
|
380
|
+
}, "blah: expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String]");
|
381
|
+
});
|
382
|
+
|
383
|
+
it('ownProperty(name)', function(){
|
384
|
+
'test'.should.have.ownProperty('length');
|
385
|
+
'test'.should.haveOwnProperty('length');
|
386
|
+
({ length: 12 }).should.have.ownProperty('length');
|
387
|
+
|
388
|
+
err(function(){
|
389
|
+
({ length: 12 }).should.not.have.ownProperty('length', 'blah');
|
390
|
+
}, "blah: expected { length: 12 } to not have own property 'length'");
|
391
|
+
});
|
392
|
+
|
393
|
+
it('string()', function(){
|
394
|
+
'foobar'.should.contain.string('bar');
|
395
|
+
'foobar'.should.contain.string('foo');
|
396
|
+
'foobar'.should.not.contain.string('baz');
|
397
|
+
|
398
|
+
err(function(){
|
399
|
+
(3).should.contain.string('baz', 'blah');
|
400
|
+
}, "blah: expected 3 to be a string");
|
401
|
+
|
402
|
+
err(function(){
|
403
|
+
'foobar'.should.contain.string('baz', 'blah');
|
404
|
+
}, "blah: expected 'foobar' to contain 'baz'");
|
405
|
+
|
406
|
+
err(function(){
|
407
|
+
'foobar'.should.not.contain.string('bar', 'blah');
|
408
|
+
}, "blah: expected 'foobar' to not contain 'bar'");
|
409
|
+
});
|
410
|
+
|
411
|
+
it('include()', function(){
|
412
|
+
['foo', 'bar'].should.include('foo');
|
413
|
+
['foo', 'bar'].should.contain('foo');
|
414
|
+
['foo', 'bar'].should.include('bar');
|
415
|
+
[1,2].should.include(1);
|
416
|
+
['foo', 'bar'].should.not.include('baz');
|
417
|
+
['foo', 'bar'].should.not.include(1);
|
418
|
+
({a:1,b:2}).should.include({b:2});
|
419
|
+
({a:1,b:2}).should.not.include({b:3});
|
420
|
+
|
421
|
+
err(function(){
|
422
|
+
['foo'].should.include('bar', 'blah');
|
423
|
+
}, "blah: expected [ 'foo' ] to include 'bar'");
|
424
|
+
|
425
|
+
err(function(){
|
426
|
+
['bar', 'foo'].should.not.include('foo', 'blah');
|
427
|
+
}, "blah: expected [ 'bar', 'foo' ] to not include 'foo'");
|
428
|
+
|
429
|
+
err(function(){
|
430
|
+
({a:1}).should.include({b:2});
|
431
|
+
}, "expected { a: 1 } to have a property 'b'")
|
432
|
+
});
|
433
|
+
|
434
|
+
it('keys(array)', function(){
|
435
|
+
({ foo: 1 }).should.have.keys(['foo']);
|
436
|
+
({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']);
|
437
|
+
({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar');
|
438
|
+
({ foo: 1, bar: 2, baz: 3 }).should.include.keys('foo', 'bar');
|
439
|
+
({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('bar', 'foo');
|
440
|
+
({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('baz');
|
441
|
+
|
442
|
+
({ foo: 1, bar: 2 }).should.contain.keys('foo');
|
443
|
+
({ foo: 1, bar: 2 }).should.contain.keys('bar', 'foo');
|
444
|
+
({ foo: 1, bar: 2 }).should.contain.keys(['foo']);
|
445
|
+
({ foo: 1, bar: 2 }).should.contain.keys(['bar']);
|
446
|
+
({ foo: 1, bar: 2 }).should.contain.keys(['bar', 'foo']);
|
447
|
+
|
448
|
+
({ foo: 1, bar: 2 }).should.not.have.keys('baz');
|
449
|
+
({ foo: 1, bar: 2 }).should.not.have.keys('foo', 'baz');
|
450
|
+
({ foo: 1, bar: 2 }).should.not.contain.keys('baz');
|
451
|
+
({ foo: 1, bar: 2 }).should.not.contain.keys('foo', 'baz');
|
452
|
+
({ foo: 1, bar: 2 }).should.not.contain.keys('baz', 'foo');
|
453
|
+
|
454
|
+
err(function(){
|
455
|
+
({ foo: 1 }).should.have.keys();
|
456
|
+
}, "keys required");
|
457
|
+
|
458
|
+
err(function(){
|
459
|
+
({ foo: 1 }).should.have.keys([]);
|
460
|
+
}, "keys required");
|
461
|
+
|
462
|
+
err(function(){
|
463
|
+
({ foo: 1 }).should.not.have.keys([]);
|
464
|
+
}, "keys required");
|
465
|
+
|
466
|
+
err(function(){
|
467
|
+
({ foo: 1 }).should.contain.keys([]);
|
468
|
+
}, "keys required");
|
469
|
+
|
470
|
+
err(function(){
|
471
|
+
({ foo: 1 }).should.have.keys(['bar']);
|
472
|
+
}, "expected { foo: 1 } to have key 'bar'");
|
473
|
+
|
474
|
+
err(function(){
|
475
|
+
({ foo: 1 }).should.have.keys(['bar', 'baz']);
|
476
|
+
}, "expected { foo: 1 } to have keys 'bar', and 'baz'");
|
477
|
+
|
478
|
+
err(function(){
|
479
|
+
({ foo: 1 }).should.have.keys(['foo', 'bar', 'baz']);
|
480
|
+
}, "expected { foo: 1 } to have keys 'foo', 'bar', and 'baz'");
|
481
|
+
|
482
|
+
err(function(){
|
483
|
+
({ foo: 1 }).should.not.have.keys(['foo']);
|
484
|
+
}, "expected { foo: 1 } to not have key 'foo'");
|
485
|
+
|
486
|
+
err(function(){
|
487
|
+
({ foo: 1 }).should.not.have.keys(['foo']);
|
488
|
+
}, "expected { foo: 1 } to not have key 'foo'");
|
489
|
+
|
490
|
+
err(function(){
|
491
|
+
({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']);
|
492
|
+
}, "expected { foo: 1, bar: 2 } to not have keys 'foo', and 'bar'");
|
493
|
+
|
494
|
+
err(function(){
|
495
|
+
({ foo: 1 }).should.not.contain.keys(['foo']);
|
496
|
+
}, "expected { foo: 1 } to not contain key 'foo'");
|
497
|
+
|
498
|
+
err(function(){
|
499
|
+
({ foo: 1 }).should.contain.keys('foo', 'bar');
|
500
|
+
}, "expected { foo: 1 } to contain keys 'foo', and 'bar'");
|
501
|
+
});
|
502
|
+
|
503
|
+
it('throw', function () {
|
504
|
+
// See GH-45: some poorly-constructed custom errors don't have useful names
|
505
|
+
// on either their constructor or their constructor prototype, but instead
|
506
|
+
// only set the name inside the constructor itself.
|
507
|
+
var PoorlyConstructedError = function () {
|
508
|
+
this.name = 'PoorlyConstructedError';
|
509
|
+
};
|
510
|
+
PoorlyConstructedError.prototype = Object.create(Error.prototype);
|
511
|
+
|
512
|
+
function CustomError(message) {
|
513
|
+
this.name = 'CustomError';
|
514
|
+
this.message = message;
|
515
|
+
}
|
516
|
+
CustomError.prototype = Error.prototype;
|
517
|
+
|
518
|
+
var specificError = new RangeError('boo');
|
519
|
+
|
520
|
+
var goodFn = function () { 1==1; }
|
521
|
+
, badFn = function () { throw new Error('testing'); }
|
522
|
+
, stringErrFn = function () { throw 'testing'; }
|
523
|
+
, refErrFn = function () { throw new ReferenceError('hello'); }
|
524
|
+
, ickyErrFn = function () { throw new PoorlyConstructedError(); }
|
525
|
+
, specificErrFn = function () { throw specificError; }
|
526
|
+
, customErrFn = function() { throw new CustomError('foo'); };
|
527
|
+
|
528
|
+
(goodFn).should.not.throw();
|
529
|
+
(goodFn).should.not.throw(Error);
|
530
|
+
(goodFn).should.not.throw(specificError);
|
531
|
+
(badFn).should.throw();
|
532
|
+
(badFn).should.throw(Error);
|
533
|
+
(badFn).should.not.throw(ReferenceError);
|
534
|
+
(badFn).should.not.throw(specificError);
|
535
|
+
(stringErrFn).should.throw();
|
536
|
+
(stringErrFn).should.not.throw(ReferenceError);
|
537
|
+
(stringErrFn).should.not.throw(specificError);
|
538
|
+
(refErrFn).should.throw();
|
539
|
+
(refErrFn).should.throw(ReferenceError);
|
540
|
+
(refErrFn).should.throw(Error);
|
541
|
+
(refErrFn).should.not.throw(TypeError);
|
542
|
+
(refErrFn).should.not.throw(specificError);
|
543
|
+
(ickyErrFn).should.throw();
|
544
|
+
(ickyErrFn).should.throw(PoorlyConstructedError);
|
545
|
+
(ickyErrFn).should.throw(Error);
|
546
|
+
(ickyErrFn).should.not.throw(specificError);
|
547
|
+
(specificErrFn).should.throw(specificError);
|
548
|
+
|
549
|
+
(badFn).should.throw(/testing/);
|
550
|
+
(badFn).should.throw('testing');
|
551
|
+
(badFn).should.not.throw(/hello/);
|
552
|
+
(badFn).should.not.throw('hello');
|
553
|
+
(badFn).should.throw(Error, /testing/);
|
554
|
+
(badFn).should.throw(Error, 'testing');
|
555
|
+
|
556
|
+
(stringErrFn).should.throw(/testing/);
|
557
|
+
(stringErrFn).should.throw('testing');
|
558
|
+
(stringErrFn).should.not.throw(/hello/);
|
559
|
+
(stringErrFn).should.not.throw('hello');
|
560
|
+
|
561
|
+
should.throw(badFn);
|
562
|
+
should.throw(refErrFn, ReferenceError);
|
563
|
+
should.throw(refErrFn, Error);
|
564
|
+
should.throw(ickyErrFn, PoorlyConstructedError);
|
565
|
+
should.throw(specificErrFn, specificError);
|
566
|
+
should.not.throw(goodFn);
|
567
|
+
should.not.throw(badFn, ReferenceError);
|
568
|
+
should.not.throw(badFn, specificError);
|
569
|
+
|
570
|
+
should.throw(badFn, Error, /testing/);
|
571
|
+
should.throw(badFn, Error, 'testing');
|
572
|
+
|
573
|
+
err(function(){
|
574
|
+
(goodFn).should.throw();
|
575
|
+
}, "expected [Function] to throw an error");
|
576
|
+
|
577
|
+
err(function(){
|
578
|
+
(goodFn).should.throw(ReferenceError);
|
579
|
+
}, "expected [Function] to throw ReferenceError");
|
580
|
+
|
581
|
+
err(function(){
|
582
|
+
(goodFn).should.throw(specificError);
|
583
|
+
}, "expected [Function] to throw 'RangeError: boo'");
|
584
|
+
|
585
|
+
err(function(){
|
586
|
+
(badFn).should.not.throw();
|
587
|
+
}, "expected [Function] to not throw an error but 'Error: testing' was thrown");
|
588
|
+
|
589
|
+
err(function(){
|
590
|
+
(badFn).should.throw(ReferenceError);
|
591
|
+
}, "expected [Function] to throw 'ReferenceError' but 'Error: testing' was thrown");
|
592
|
+
|
593
|
+
err(function(){
|
594
|
+
(badFn).should.throw(specificError);
|
595
|
+
}, "expected [Function] to throw 'RangeError: boo' but 'Error: testing' was thrown");
|
596
|
+
|
597
|
+
err(function(){
|
598
|
+
(badFn).should.not.throw(Error);
|
599
|
+
}, "expected [Function] to not throw 'Error' but 'Error: testing' was thrown");
|
600
|
+
|
601
|
+
err(function(){
|
602
|
+
(stringErrFn).should.not.throw();
|
603
|
+
}, "expected [Function] to not throw an error but 'testing' was thrown");
|
604
|
+
|
605
|
+
err(function(){
|
606
|
+
(stringErrFn).should.throw(ReferenceError);
|
607
|
+
}, "expected [Function] to throw 'ReferenceError' but 'testing' was thrown");
|
608
|
+
|
609
|
+
err(function(){
|
610
|
+
(stringErrFn).should.throw(specificError);
|
611
|
+
}, "expected [Function] to throw 'RangeError: boo' but 'testing' was thrown");
|
612
|
+
|
613
|
+
err(function(){
|
614
|
+
(stringErrFn).should.not.throw('testing');
|
615
|
+
}, "expected [Function] to throw error not including 'testing'");
|
616
|
+
|
617
|
+
err(function(){
|
618
|
+
(refErrFn).should.not.throw(ReferenceError);
|
619
|
+
}, "expected [Function] to not throw 'ReferenceError' but 'ReferenceError: hello' was thrown");
|
620
|
+
|
621
|
+
err(function(){
|
622
|
+
(badFn).should.throw(PoorlyConstructedError);
|
623
|
+
}, "expected [Function] to throw 'PoorlyConstructedError' but 'Error: testing' was thrown")
|
624
|
+
|
625
|
+
err(function(){
|
626
|
+
(ickyErrFn).should.not.throw(PoorlyConstructedError);
|
627
|
+
}, /^(expected \[Function\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
628
|
+
|
629
|
+
err(function(){
|
630
|
+
(ickyErrFn).should.throw(ReferenceError);
|
631
|
+
}, /^(expected \[Function\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
632
|
+
|
633
|
+
err(function(){
|
634
|
+
(specificErrFn).should.throw(new ReferenceError('eek'));
|
635
|
+
}, "expected [Function] to throw 'ReferenceError: eek' but 'RangeError: boo' was thrown");
|
636
|
+
|
637
|
+
err(function(){
|
638
|
+
(specificErrFn).should.not.throw(specificError);
|
639
|
+
}, "expected [Function] to not throw 'RangeError: boo'");
|
640
|
+
|
641
|
+
err(function (){
|
642
|
+
(badFn).should.not.throw(/testing/);
|
643
|
+
}, "expected [Function] to throw error not matching /testing/");
|
644
|
+
|
645
|
+
err(function () {
|
646
|
+
(badFn).should.throw(/hello/);
|
647
|
+
}, "expected [Function] to throw error matching /hello/ but got \'testing\'");
|
648
|
+
|
649
|
+
err(function () {
|
650
|
+
(badFn).should.throw(Error, /hello/, 'blah');
|
651
|
+
}, "blah: expected [Function] to throw error matching /hello/ but got 'testing'");
|
652
|
+
|
653
|
+
err(function () {
|
654
|
+
(badFn).should.throw(Error, 'hello', 'blah');
|
655
|
+
}, "blah: expected [Function] to throw error including 'hello' but got 'testing'");
|
656
|
+
|
657
|
+
err(function () {
|
658
|
+
(customErrFn).should.not.throw();
|
659
|
+
}, "expected [Function] to not throw an error but 'CustomError: foo' was thrown");
|
660
|
+
});
|
661
|
+
|
662
|
+
it('respondTo', function(){
|
663
|
+
function Foo(){};
|
664
|
+
Foo.prototype.bar = function(){};
|
665
|
+
Foo.func = function(){};
|
666
|
+
|
667
|
+
var bar = {};
|
668
|
+
bar.foo = function(){};
|
669
|
+
|
670
|
+
Foo.should.respondTo('bar');
|
671
|
+
Foo.should.not.respondTo('foo');
|
672
|
+
Foo.should.itself.respondTo('func');
|
673
|
+
Foo.should.itself.not.respondTo('bar');
|
674
|
+
|
675
|
+
bar.should.respondTo('foo');
|
676
|
+
|
677
|
+
err(function(){
|
678
|
+
Foo.should.respondTo('baz', 'constructor');
|
679
|
+
}, /^(constructor: expected)(.*)(\[Function: Foo\])(.*)(to respond to \'baz\')$/);
|
680
|
+
|
681
|
+
err(function(){
|
682
|
+
bar.should.respondTo('baz', 'object');
|
683
|
+
}, /^(object: expected)(.*)(\{ foo: \[Function\] \}|\{ Object \()(.*)(to respond to \'baz\')$/);
|
684
|
+
});
|
685
|
+
|
686
|
+
it('satisfy', function(){
|
687
|
+
var matcher = function (num){
|
688
|
+
return num === 1;
|
689
|
+
};
|
690
|
+
|
691
|
+
(1).should.satisfy(matcher);
|
692
|
+
|
693
|
+
err(function(){
|
694
|
+
(2).should.satisfy(matcher, 'blah');
|
695
|
+
}, "blah: expected 2 to satisfy [Function]");
|
696
|
+
});
|
697
|
+
|
698
|
+
it('closeTo', function(){
|
699
|
+
(1.5).should.be.closeTo(1.0, 0.5);
|
700
|
+
|
701
|
+
err(function(){
|
702
|
+
(2).should.be.closeTo(1.0, 0.5, 'blah');
|
703
|
+
}, "blah: expected 2 to be close to 1 +/- 0.5");
|
704
|
+
});
|
705
|
+
|
706
|
+
it('include.members', function() {
|
707
|
+
[1, 2, 3].should.include.members([3]);
|
708
|
+
[1, 2, 3].should.include.members([]);
|
709
|
+
[1, 2, 3].should.include.members([2, 1]);
|
710
|
+
|
711
|
+
[1, 2, 3].should.not.include.members([999]);
|
712
|
+
[].should.not.include.members([23]);
|
713
|
+
|
714
|
+
err(function() {
|
715
|
+
[].should.include.members([43]);
|
716
|
+
}, 'expected [] to be a superset of [ 43 ]');
|
717
|
+
|
718
|
+
err(function() {
|
719
|
+
[5, 2, 1].should.not.include.members([2]);
|
720
|
+
}, 'expected [ 5, 2, 1 ] to not be a superset of [ 2 ]');
|
721
|
+
|
722
|
+
err(function() {
|
723
|
+
'foo'.should.include.members([12]);
|
724
|
+
}, "expected 'foo' to be an array");
|
725
|
+
|
726
|
+
err(function() {
|
727
|
+
[1, 2, 3].should.include.members('o');
|
728
|
+
}, "expected 'o' to be an array");
|
729
|
+
});
|
730
|
+
|
731
|
+
it('memberEquals', function() {
|
732
|
+
[1, 2, 3].should.have.same.members([3, 2, 1]);
|
733
|
+
[5, 4].should.have.same.members([5, 4]);
|
734
|
+
[].should.have.same.members([]);
|
735
|
+
|
736
|
+
err(function() {
|
737
|
+
[1, 2, 3].should.have.same.members([]);
|
738
|
+
}, 'expected [ 1, 2, 3 ] to have the same members as []');
|
739
|
+
|
740
|
+
err(function() {
|
741
|
+
[1, 2, 3].should.have.same.members(4);
|
742
|
+
}, 'expected 4 to be an array');
|
743
|
+
});
|
744
|
+
});
|