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,245 @@
|
|
1
|
+
/* @depend ../sinon.js */
|
2
|
+
/*jslint eqeqeq: false, onevar: false, plusplus: false*/
|
3
|
+
/*global module, require, sinon*/
|
4
|
+
/**
|
5
|
+
* Match functions
|
6
|
+
*
|
7
|
+
* @author Maximilian Antoni (mail@maxantoni.de)
|
8
|
+
* @license BSD
|
9
|
+
*
|
10
|
+
* Copyright (c) 2012 Maximilian Antoni
|
11
|
+
*/
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
(function (sinon) {
|
15
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
16
|
+
|
17
|
+
if (!sinon && commonJSModule) {
|
18
|
+
sinon = require("../sinon");
|
19
|
+
}
|
20
|
+
|
21
|
+
if (!sinon) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
25
|
+
function assertType(value, type, name) {
|
26
|
+
var actual = sinon.typeOf(value);
|
27
|
+
if (actual !== type) {
|
28
|
+
throw new TypeError("Expected type of " + name + " to be " +
|
29
|
+
type + ", but was " + actual);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
var matcher = {
|
34
|
+
toString: function () {
|
35
|
+
return this.message;
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
function isMatcher(object) {
|
40
|
+
return matcher.isPrototypeOf(object);
|
41
|
+
}
|
42
|
+
|
43
|
+
function matchObject(expectation, actual) {
|
44
|
+
if (actual === null || actual === undefined) {
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
for (var key in expectation) {
|
48
|
+
if (expectation.hasOwnProperty(key)) {
|
49
|
+
var exp = expectation[key];
|
50
|
+
var act = actual[key];
|
51
|
+
if (match.isMatcher(exp)) {
|
52
|
+
if (!exp.test(act)) {
|
53
|
+
return false;
|
54
|
+
}
|
55
|
+
} else if (sinon.typeOf(exp) === "object") {
|
56
|
+
if (!matchObject(exp, act)) {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
} else if (!sinon.deepEqual(exp, act)) {
|
60
|
+
return false;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
return true;
|
65
|
+
}
|
66
|
+
|
67
|
+
matcher.or = function (m2) {
|
68
|
+
if (!arguments.length) {
|
69
|
+
throw new TypeError("Matcher expected");
|
70
|
+
} else if (!isMatcher(m2)) {
|
71
|
+
m2 = match(m2);
|
72
|
+
}
|
73
|
+
var m1 = this;
|
74
|
+
var or = sinon.create(matcher);
|
75
|
+
or.test = function (actual) {
|
76
|
+
return m1.test(actual) || m2.test(actual);
|
77
|
+
};
|
78
|
+
or.message = m1.message + ".or(" + m2.message + ")";
|
79
|
+
return or;
|
80
|
+
};
|
81
|
+
|
82
|
+
matcher.and = function (m2) {
|
83
|
+
if (!arguments.length) {
|
84
|
+
throw new TypeError("Matcher expected");
|
85
|
+
} else if (!isMatcher(m2)) {
|
86
|
+
m2 = match(m2);
|
87
|
+
}
|
88
|
+
var m1 = this;
|
89
|
+
var and = sinon.create(matcher);
|
90
|
+
and.test = function (actual) {
|
91
|
+
return m1.test(actual) && m2.test(actual);
|
92
|
+
};
|
93
|
+
and.message = m1.message + ".and(" + m2.message + ")";
|
94
|
+
return and;
|
95
|
+
};
|
96
|
+
|
97
|
+
var match = function (expectation, message) {
|
98
|
+
var m = sinon.create(matcher);
|
99
|
+
var type = sinon.typeOf(expectation);
|
100
|
+
switch (type) {
|
101
|
+
case "object":
|
102
|
+
if (typeof expectation.test === "function") {
|
103
|
+
m.test = function (actual) {
|
104
|
+
return expectation.test(actual) === true;
|
105
|
+
};
|
106
|
+
m.message = "match(" + sinon.functionName(expectation.test) + ")";
|
107
|
+
return m;
|
108
|
+
}
|
109
|
+
var str = [];
|
110
|
+
for (var key in expectation) {
|
111
|
+
if (expectation.hasOwnProperty(key)) {
|
112
|
+
str.push(key + ": " + expectation[key]);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
m.test = function (actual) {
|
116
|
+
return matchObject(expectation, actual);
|
117
|
+
};
|
118
|
+
m.message = "match(" + str.join(", ") + ")";
|
119
|
+
break;
|
120
|
+
case "number":
|
121
|
+
m.test = function (actual) {
|
122
|
+
return expectation == actual;
|
123
|
+
};
|
124
|
+
break;
|
125
|
+
case "string":
|
126
|
+
m.test = function (actual) {
|
127
|
+
if (typeof actual !== "string") {
|
128
|
+
return false;
|
129
|
+
}
|
130
|
+
return actual.indexOf(expectation) !== -1;
|
131
|
+
};
|
132
|
+
m.message = "match(\"" + expectation + "\")";
|
133
|
+
break;
|
134
|
+
case "regexp":
|
135
|
+
m.test = function (actual) {
|
136
|
+
if (typeof actual !== "string") {
|
137
|
+
return false;
|
138
|
+
}
|
139
|
+
return expectation.test(actual);
|
140
|
+
};
|
141
|
+
break;
|
142
|
+
case "function":
|
143
|
+
m.test = expectation;
|
144
|
+
if (message) {
|
145
|
+
m.message = message;
|
146
|
+
} else {
|
147
|
+
m.message = "match(" + sinon.functionName(expectation) + ")";
|
148
|
+
}
|
149
|
+
break;
|
150
|
+
default:
|
151
|
+
m.test = function (actual) {
|
152
|
+
return sinon.deepEqual(expectation, actual);
|
153
|
+
};
|
154
|
+
}
|
155
|
+
if (!m.message) {
|
156
|
+
m.message = "match(" + expectation + ")";
|
157
|
+
}
|
158
|
+
return m;
|
159
|
+
};
|
160
|
+
|
161
|
+
match.isMatcher = isMatcher;
|
162
|
+
|
163
|
+
match.any = match(function () {
|
164
|
+
return true;
|
165
|
+
}, "any");
|
166
|
+
|
167
|
+
match.defined = match(function (actual) {
|
168
|
+
return actual !== null && actual !== undefined;
|
169
|
+
}, "defined");
|
170
|
+
|
171
|
+
match.truthy = match(function (actual) {
|
172
|
+
return !!actual;
|
173
|
+
}, "truthy");
|
174
|
+
|
175
|
+
match.falsy = match(function (actual) {
|
176
|
+
return !actual;
|
177
|
+
}, "falsy");
|
178
|
+
|
179
|
+
match.same = function (expectation) {
|
180
|
+
return match(function (actual) {
|
181
|
+
return expectation === actual;
|
182
|
+
}, "same(" + expectation + ")");
|
183
|
+
};
|
184
|
+
|
185
|
+
match.typeOf = function (type) {
|
186
|
+
assertType(type, "string", "type");
|
187
|
+
return match(function (actual) {
|
188
|
+
return sinon.typeOf(actual) === type;
|
189
|
+
}, "typeOf(\"" + type + "\")");
|
190
|
+
};
|
191
|
+
|
192
|
+
match.instanceOf = function (type) {
|
193
|
+
assertType(type, "function", "type");
|
194
|
+
return match(function (actual) {
|
195
|
+
return actual instanceof type;
|
196
|
+
}, "instanceOf(" + sinon.functionName(type) + ")");
|
197
|
+
};
|
198
|
+
|
199
|
+
function createPropertyMatcher(propertyTest, messagePrefix) {
|
200
|
+
return function (property, value) {
|
201
|
+
assertType(property, "string", "property");
|
202
|
+
var onlyProperty = arguments.length === 1;
|
203
|
+
var message = messagePrefix + "(\"" + property + "\"";
|
204
|
+
if (!onlyProperty) {
|
205
|
+
message += ", " + value;
|
206
|
+
}
|
207
|
+
message += ")";
|
208
|
+
return match(function (actual) {
|
209
|
+
if (actual === undefined || actual === null ||
|
210
|
+
!propertyTest(actual, property)) {
|
211
|
+
return false;
|
212
|
+
}
|
213
|
+
return onlyProperty || sinon.deepEqual(value, actual[property]);
|
214
|
+
}, message);
|
215
|
+
};
|
216
|
+
}
|
217
|
+
|
218
|
+
match.has = createPropertyMatcher(function (actual, property) {
|
219
|
+
if (typeof actual === "object") {
|
220
|
+
return property in actual;
|
221
|
+
}
|
222
|
+
return actual[property] !== undefined;
|
223
|
+
}, "has");
|
224
|
+
|
225
|
+
match.hasOwn = createPropertyMatcher(function (actual, property) {
|
226
|
+
return actual.hasOwnProperty(property);
|
227
|
+
}, "hasOwn");
|
228
|
+
|
229
|
+
match.bool = match.typeOf("boolean");
|
230
|
+
match.number = match.typeOf("number");
|
231
|
+
match.string = match.typeOf("string");
|
232
|
+
match.object = match.typeOf("object");
|
233
|
+
match.func = match.typeOf("function");
|
234
|
+
match.array = match.typeOf("array");
|
235
|
+
match.regexp = match.typeOf("regexp");
|
236
|
+
match.date = match.typeOf("date");
|
237
|
+
|
238
|
+
sinon.match = match;
|
239
|
+
|
240
|
+
if (typeof define === "function" && define.amd) {
|
241
|
+
define(["module"], function(module) { module.exports = match; });
|
242
|
+
} else if (commonJSModule) {
|
243
|
+
module.exports = match;
|
244
|
+
}
|
245
|
+
}(typeof sinon == "object" && sinon || null));
|
@@ -0,0 +1,451 @@
|
|
1
|
+
/**
|
2
|
+
* @depend ../sinon.js
|
3
|
+
* @depend stub.js
|
4
|
+
*/
|
5
|
+
/*jslint eqeqeq: false, onevar: false, nomen: false*/
|
6
|
+
/*global module, require, sinon*/
|
7
|
+
/**
|
8
|
+
* Mock functions.
|
9
|
+
*
|
10
|
+
* @author Christian Johansen (christian@cjohansen.no)
|
11
|
+
* @license BSD
|
12
|
+
*
|
13
|
+
* Copyright (c) 2010-2013 Christian Johansen
|
14
|
+
*/
|
15
|
+
"use strict";
|
16
|
+
|
17
|
+
(function (sinon) {
|
18
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
19
|
+
var push = [].push;
|
20
|
+
var match;
|
21
|
+
|
22
|
+
if (!sinon && commonJSModule) {
|
23
|
+
sinon = require("../sinon");
|
24
|
+
}
|
25
|
+
|
26
|
+
if (!sinon) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
match = sinon.match;
|
31
|
+
|
32
|
+
if (!match && commonJSModule) {
|
33
|
+
match = require("./match");
|
34
|
+
}
|
35
|
+
|
36
|
+
function mock(object) {
|
37
|
+
if (!object) {
|
38
|
+
return sinon.expectation.create("Anonymous mock");
|
39
|
+
}
|
40
|
+
|
41
|
+
return mock.create(object);
|
42
|
+
}
|
43
|
+
|
44
|
+
sinon.mock = mock;
|
45
|
+
|
46
|
+
sinon.extend(mock, (function () {
|
47
|
+
function each(collection, callback) {
|
48
|
+
if (!collection) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
|
52
|
+
for (var i = 0, l = collection.length; i < l; i += 1) {
|
53
|
+
callback(collection[i]);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
return {
|
58
|
+
create: function create(object) {
|
59
|
+
if (!object) {
|
60
|
+
throw new TypeError("object is null");
|
61
|
+
}
|
62
|
+
|
63
|
+
var mockObject = sinon.extend({}, mock);
|
64
|
+
mockObject.object = object;
|
65
|
+
delete mockObject.create;
|
66
|
+
|
67
|
+
return mockObject;
|
68
|
+
},
|
69
|
+
|
70
|
+
expects: function expects(method) {
|
71
|
+
if (!method) {
|
72
|
+
throw new TypeError("method is falsy");
|
73
|
+
}
|
74
|
+
|
75
|
+
if (!this.expectations) {
|
76
|
+
this.expectations = {};
|
77
|
+
this.proxies = [];
|
78
|
+
}
|
79
|
+
|
80
|
+
if (!this.expectations[method]) {
|
81
|
+
this.expectations[method] = [];
|
82
|
+
var mockObject = this;
|
83
|
+
|
84
|
+
sinon.wrapMethod(this.object, method, function () {
|
85
|
+
return mockObject.invokeMethod(method, this, arguments);
|
86
|
+
});
|
87
|
+
|
88
|
+
push.call(this.proxies, method);
|
89
|
+
}
|
90
|
+
|
91
|
+
var expectation = sinon.expectation.create(method);
|
92
|
+
push.call(this.expectations[method], expectation);
|
93
|
+
|
94
|
+
return expectation;
|
95
|
+
},
|
96
|
+
|
97
|
+
restore: function restore() {
|
98
|
+
var object = this.object;
|
99
|
+
|
100
|
+
each(this.proxies, function (proxy) {
|
101
|
+
if (typeof object[proxy].restore == "function") {
|
102
|
+
object[proxy].restore();
|
103
|
+
}
|
104
|
+
});
|
105
|
+
},
|
106
|
+
|
107
|
+
verify: function verify() {
|
108
|
+
var expectations = this.expectations || {};
|
109
|
+
var messages = [], met = [];
|
110
|
+
|
111
|
+
each(this.proxies, function (proxy) {
|
112
|
+
each(expectations[proxy], function (expectation) {
|
113
|
+
if (!expectation.met()) {
|
114
|
+
push.call(messages, expectation.toString());
|
115
|
+
} else {
|
116
|
+
push.call(met, expectation.toString());
|
117
|
+
}
|
118
|
+
});
|
119
|
+
});
|
120
|
+
|
121
|
+
this.restore();
|
122
|
+
|
123
|
+
if (messages.length > 0) {
|
124
|
+
sinon.expectation.fail(messages.concat(met).join("\n"));
|
125
|
+
} else {
|
126
|
+
sinon.expectation.pass(messages.concat(met).join("\n"));
|
127
|
+
}
|
128
|
+
|
129
|
+
return true;
|
130
|
+
},
|
131
|
+
|
132
|
+
invokeMethod: function invokeMethod(method, thisValue, args) {
|
133
|
+
var expectations = this.expectations && this.expectations[method];
|
134
|
+
var length = expectations && expectations.length || 0, i;
|
135
|
+
|
136
|
+
for (i = 0; i < length; i += 1) {
|
137
|
+
if (!expectations[i].met() &&
|
138
|
+
expectations[i].allowsCall(thisValue, args)) {
|
139
|
+
return expectations[i].apply(thisValue, args);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
var messages = [], available, exhausted = 0;
|
144
|
+
|
145
|
+
for (i = 0; i < length; i += 1) {
|
146
|
+
if (expectations[i].allowsCall(thisValue, args)) {
|
147
|
+
available = available || expectations[i];
|
148
|
+
} else {
|
149
|
+
exhausted += 1;
|
150
|
+
}
|
151
|
+
push.call(messages, " " + expectations[i].toString());
|
152
|
+
}
|
153
|
+
|
154
|
+
if (exhausted === 0) {
|
155
|
+
return available.apply(thisValue, args);
|
156
|
+
}
|
157
|
+
|
158
|
+
messages.unshift("Unexpected call: " + sinon.spyCall.toString.call({
|
159
|
+
proxy: method,
|
160
|
+
args: args
|
161
|
+
}));
|
162
|
+
|
163
|
+
sinon.expectation.fail(messages.join("\n"));
|
164
|
+
}
|
165
|
+
};
|
166
|
+
}()));
|
167
|
+
|
168
|
+
var times = sinon.timesInWords;
|
169
|
+
|
170
|
+
sinon.expectation = (function () {
|
171
|
+
var slice = Array.prototype.slice;
|
172
|
+
var _invoke = sinon.spy.invoke;
|
173
|
+
|
174
|
+
function callCountInWords(callCount) {
|
175
|
+
if (callCount == 0) {
|
176
|
+
return "never called";
|
177
|
+
} else {
|
178
|
+
return "called " + times(callCount);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
function expectedCallCountInWords(expectation) {
|
183
|
+
var min = expectation.minCalls;
|
184
|
+
var max = expectation.maxCalls;
|
185
|
+
|
186
|
+
if (typeof min == "number" && typeof max == "number") {
|
187
|
+
var str = times(min);
|
188
|
+
|
189
|
+
if (min != max) {
|
190
|
+
str = "at least " + str + " and at most " + times(max);
|
191
|
+
}
|
192
|
+
|
193
|
+
return str;
|
194
|
+
}
|
195
|
+
|
196
|
+
if (typeof min == "number") {
|
197
|
+
return "at least " + times(min);
|
198
|
+
}
|
199
|
+
|
200
|
+
return "at most " + times(max);
|
201
|
+
}
|
202
|
+
|
203
|
+
function receivedMinCalls(expectation) {
|
204
|
+
var hasMinLimit = typeof expectation.minCalls == "number";
|
205
|
+
return !hasMinLimit || expectation.callCount >= expectation.minCalls;
|
206
|
+
}
|
207
|
+
|
208
|
+
function receivedMaxCalls(expectation) {
|
209
|
+
if (typeof expectation.maxCalls != "number") {
|
210
|
+
return false;
|
211
|
+
}
|
212
|
+
|
213
|
+
return expectation.callCount == expectation.maxCalls;
|
214
|
+
}
|
215
|
+
|
216
|
+
function verifyMatcher(possibleMatcher, arg){
|
217
|
+
if (match && match.isMatcher(possibleMatcher)) {
|
218
|
+
return possibleMatcher.test(arg);
|
219
|
+
} else {
|
220
|
+
return true;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
return {
|
225
|
+
minCalls: 1,
|
226
|
+
maxCalls: 1,
|
227
|
+
|
228
|
+
create: function create(methodName) {
|
229
|
+
var expectation = sinon.extend(sinon.stub.create(), sinon.expectation);
|
230
|
+
delete expectation.create;
|
231
|
+
expectation.method = methodName;
|
232
|
+
|
233
|
+
return expectation;
|
234
|
+
},
|
235
|
+
|
236
|
+
invoke: function invoke(func, thisValue, args) {
|
237
|
+
this.verifyCallAllowed(thisValue, args);
|
238
|
+
|
239
|
+
return _invoke.apply(this, arguments);
|
240
|
+
},
|
241
|
+
|
242
|
+
atLeast: function atLeast(num) {
|
243
|
+
if (typeof num != "number") {
|
244
|
+
throw new TypeError("'" + num + "' is not number");
|
245
|
+
}
|
246
|
+
|
247
|
+
if (!this.limitsSet) {
|
248
|
+
this.maxCalls = null;
|
249
|
+
this.limitsSet = true;
|
250
|
+
}
|
251
|
+
|
252
|
+
this.minCalls = num;
|
253
|
+
|
254
|
+
return this;
|
255
|
+
},
|
256
|
+
|
257
|
+
atMost: function atMost(num) {
|
258
|
+
if (typeof num != "number") {
|
259
|
+
throw new TypeError("'" + num + "' is not number");
|
260
|
+
}
|
261
|
+
|
262
|
+
if (!this.limitsSet) {
|
263
|
+
this.minCalls = null;
|
264
|
+
this.limitsSet = true;
|
265
|
+
}
|
266
|
+
|
267
|
+
this.maxCalls = num;
|
268
|
+
|
269
|
+
return this;
|
270
|
+
},
|
271
|
+
|
272
|
+
never: function never() {
|
273
|
+
return this.exactly(0);
|
274
|
+
},
|
275
|
+
|
276
|
+
once: function once() {
|
277
|
+
return this.exactly(1);
|
278
|
+
},
|
279
|
+
|
280
|
+
twice: function twice() {
|
281
|
+
return this.exactly(2);
|
282
|
+
},
|
283
|
+
|
284
|
+
thrice: function thrice() {
|
285
|
+
return this.exactly(3);
|
286
|
+
},
|
287
|
+
|
288
|
+
exactly: function exactly(num) {
|
289
|
+
if (typeof num != "number") {
|
290
|
+
throw new TypeError("'" + num + "' is not a number");
|
291
|
+
}
|
292
|
+
|
293
|
+
this.atLeast(num);
|
294
|
+
return this.atMost(num);
|
295
|
+
},
|
296
|
+
|
297
|
+
met: function met() {
|
298
|
+
return !this.failed && receivedMinCalls(this);
|
299
|
+
},
|
300
|
+
|
301
|
+
verifyCallAllowed: function verifyCallAllowed(thisValue, args) {
|
302
|
+
if (receivedMaxCalls(this)) {
|
303
|
+
this.failed = true;
|
304
|
+
sinon.expectation.fail(this.method + " already called " + times(this.maxCalls));
|
305
|
+
}
|
306
|
+
|
307
|
+
if ("expectedThis" in this && this.expectedThis !== thisValue) {
|
308
|
+
sinon.expectation.fail(this.method + " called with " + thisValue + " as thisValue, expected " +
|
309
|
+
this.expectedThis);
|
310
|
+
}
|
311
|
+
|
312
|
+
if (!("expectedArguments" in this)) {
|
313
|
+
return;
|
314
|
+
}
|
315
|
+
|
316
|
+
if (!args) {
|
317
|
+
sinon.expectation.fail(this.method + " received no arguments, expected " +
|
318
|
+
sinon.format(this.expectedArguments));
|
319
|
+
}
|
320
|
+
|
321
|
+
if (args.length < this.expectedArguments.length) {
|
322
|
+
sinon.expectation.fail(this.method + " received too few arguments (" + sinon.format(args) +
|
323
|
+
"), expected " + sinon.format(this.expectedArguments));
|
324
|
+
}
|
325
|
+
|
326
|
+
if (this.expectsExactArgCount &&
|
327
|
+
args.length != this.expectedArguments.length) {
|
328
|
+
sinon.expectation.fail(this.method + " received too many arguments (" + sinon.format(args) +
|
329
|
+
"), expected " + sinon.format(this.expectedArguments));
|
330
|
+
}
|
331
|
+
|
332
|
+
for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) {
|
333
|
+
|
334
|
+
if (!verifyMatcher(this.expectedArguments[i],args[i])) {
|
335
|
+
sinon.expectation.fail(this.method + " received wrong arguments " + sinon.format(args) +
|
336
|
+
", didn't match " + this.expectedArguments.toString());
|
337
|
+
}
|
338
|
+
|
339
|
+
if (!sinon.deepEqual(this.expectedArguments[i], args[i])) {
|
340
|
+
sinon.expectation.fail(this.method + " received wrong arguments " + sinon.format(args) +
|
341
|
+
", expected " + sinon.format(this.expectedArguments));
|
342
|
+
}
|
343
|
+
}
|
344
|
+
},
|
345
|
+
|
346
|
+
allowsCall: function allowsCall(thisValue, args) {
|
347
|
+
if (this.met() && receivedMaxCalls(this)) {
|
348
|
+
return false;
|
349
|
+
}
|
350
|
+
|
351
|
+
if ("expectedThis" in this && this.expectedThis !== thisValue) {
|
352
|
+
return false;
|
353
|
+
}
|
354
|
+
|
355
|
+
if (!("expectedArguments" in this)) {
|
356
|
+
return true;
|
357
|
+
}
|
358
|
+
|
359
|
+
args = args || [];
|
360
|
+
|
361
|
+
if (args.length < this.expectedArguments.length) {
|
362
|
+
return false;
|
363
|
+
}
|
364
|
+
|
365
|
+
if (this.expectsExactArgCount &&
|
366
|
+
args.length != this.expectedArguments.length) {
|
367
|
+
return false;
|
368
|
+
}
|
369
|
+
|
370
|
+
for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) {
|
371
|
+
if (!verifyMatcher(this.expectedArguments[i],args[i])) {
|
372
|
+
return false;
|
373
|
+
}
|
374
|
+
|
375
|
+
if (!sinon.deepEqual(this.expectedArguments[i], args[i])) {
|
376
|
+
return false;
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
return true;
|
381
|
+
},
|
382
|
+
|
383
|
+
withArgs: function withArgs() {
|
384
|
+
this.expectedArguments = slice.call(arguments);
|
385
|
+
return this;
|
386
|
+
},
|
387
|
+
|
388
|
+
withExactArgs: function withExactArgs() {
|
389
|
+
this.withArgs.apply(this, arguments);
|
390
|
+
this.expectsExactArgCount = true;
|
391
|
+
return this;
|
392
|
+
},
|
393
|
+
|
394
|
+
on: function on(thisValue) {
|
395
|
+
this.expectedThis = thisValue;
|
396
|
+
return this;
|
397
|
+
},
|
398
|
+
|
399
|
+
toString: function () {
|
400
|
+
var args = (this.expectedArguments || []).slice();
|
401
|
+
|
402
|
+
if (!this.expectsExactArgCount) {
|
403
|
+
push.call(args, "[...]");
|
404
|
+
}
|
405
|
+
|
406
|
+
var callStr = sinon.spyCall.toString.call({
|
407
|
+
proxy: this.method || "anonymous mock expectation",
|
408
|
+
args: args
|
409
|
+
});
|
410
|
+
|
411
|
+
var message = callStr.replace(", [...", "[, ...") + " " +
|
412
|
+
expectedCallCountInWords(this);
|
413
|
+
|
414
|
+
if (this.met()) {
|
415
|
+
return "Expectation met: " + message;
|
416
|
+
}
|
417
|
+
|
418
|
+
return "Expected " + message + " (" +
|
419
|
+
callCountInWords(this.callCount) + ")";
|
420
|
+
},
|
421
|
+
|
422
|
+
verify: function verify() {
|
423
|
+
if (!this.met()) {
|
424
|
+
sinon.expectation.fail(this.toString());
|
425
|
+
} else {
|
426
|
+
sinon.expectation.pass(this.toString());
|
427
|
+
}
|
428
|
+
|
429
|
+
return true;
|
430
|
+
},
|
431
|
+
|
432
|
+
pass: function(message) {
|
433
|
+
sinon.assert.pass(message);
|
434
|
+
},
|
435
|
+
fail: function (message) {
|
436
|
+
var exception = new Error(message);
|
437
|
+
exception.name = "ExpectationError";
|
438
|
+
|
439
|
+
throw exception;
|
440
|
+
}
|
441
|
+
};
|
442
|
+
}());
|
443
|
+
|
444
|
+
sinon.mock = mock;
|
445
|
+
|
446
|
+
if (typeof define === "function" && define.amd) {
|
447
|
+
define(["module"], function(module) { module.exports = mock; });
|
448
|
+
} else if (commonJSModule) {
|
449
|
+
module.exports = mock;
|
450
|
+
}
|
451
|
+
}(typeof sinon == "object" && sinon || null));
|