@gogocat/data-bind 1.11.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +14 -14
- package/.vscode/launch.json +12 -12
- package/CONFIGURATION.md +294 -0
- package/REACTIVE_MODE.md +553 -0
- package/README.md +266 -829
- package/babel.config.json +30 -0
- package/dist/js/_escape.d.ts +14 -0
- package/dist/js/_escape.d.ts.map +1 -0
- package/dist/js/applyBinding.d.ts +11 -0
- package/dist/js/applyBinding.d.ts.map +1 -0
- package/dist/js/attrBinding.d.ts +12 -0
- package/dist/js/attrBinding.d.ts.map +1 -0
- package/dist/js/binder.d.ts +67 -0
- package/dist/js/binder.d.ts.map +1 -0
- package/dist/js/changeBinding.d.ts +19 -0
- package/dist/js/changeBinding.d.ts.map +1 -0
- package/dist/js/commentWrapper.d.ts +39 -0
- package/dist/js/commentWrapper.d.ts.map +1 -0
- package/dist/js/config.d.ts +55 -0
- package/dist/js/config.d.ts.map +1 -0
- package/dist/js/createBindingOption.d.ts +32 -0
- package/dist/js/createBindingOption.d.ts.map +1 -0
- package/dist/js/createEventBinding.d.ts +10 -0
- package/dist/js/createEventBinding.d.ts.map +1 -0
- package/dist/js/cssBinding.d.ts +15 -0
- package/dist/js/cssBinding.d.ts.map +1 -0
- package/dist/js/dataBind.js +2772 -2519
- package/dist/js/dataBind.min.js +8 -1
- package/dist/js/dataBind.min.js.map +1 -1
- package/dist/js/domWalker.d.ts +9 -0
- package/dist/js/domWalker.d.ts.map +1 -0
- package/dist/js/forOfBinding.d.ts +12 -0
- package/dist/js/forOfBinding.d.ts.map +1 -0
- package/dist/js/hoverBinding.d.ts +13 -0
- package/dist/js/hoverBinding.d.ts.map +1 -0
- package/dist/js/ifBinding.d.ts +12 -0
- package/dist/js/ifBinding.d.ts.map +1 -0
- package/dist/js/index.d.ts +10 -0
- package/dist/js/index.d.ts.map +1 -0
- package/dist/js/modelBinding.d.ts +12 -0
- package/dist/js/modelBinding.d.ts.map +1 -0
- package/dist/js/postProcess.d.ts +3 -0
- package/dist/js/postProcess.d.ts.map +1 -0
- package/dist/js/pubSub.d.ts +11 -0
- package/dist/js/pubSub.d.ts.map +1 -0
- package/dist/js/reactiveProxy.d.ts +28 -0
- package/dist/js/reactiveProxy.d.ts.map +1 -0
- package/dist/js/renderForOfBinding.d.ts +8 -0
- package/dist/js/renderForOfBinding.d.ts.map +1 -0
- package/dist/js/renderIfBinding.d.ts +22 -0
- package/dist/js/renderIfBinding.d.ts.map +1 -0
- package/dist/js/renderIteration.d.ts +16 -0
- package/dist/js/renderIteration.d.ts.map +1 -0
- package/dist/js/renderTemplate.d.ts +14 -0
- package/dist/js/renderTemplate.d.ts.map +1 -0
- package/dist/js/renderTemplatesBinding.d.ts +19 -0
- package/dist/js/renderTemplatesBinding.d.ts.map +1 -0
- package/dist/js/showBinding.d.ts +13 -0
- package/dist/js/showBinding.d.ts.map +1 -0
- package/dist/js/switchBinding.d.ts +13 -0
- package/dist/js/switchBinding.d.ts.map +1 -0
- package/dist/js/textBinding.d.ts +13 -0
- package/dist/js/textBinding.d.ts.map +1 -0
- package/dist/js/types/_escape.d.ts +14 -0
- package/dist/js/types/_escape.d.ts.map +1 -0
- package/dist/js/types/applyBinding.d.ts +11 -0
- package/dist/js/types/applyBinding.d.ts.map +1 -0
- package/dist/js/types/attrBinding.d.ts +12 -0
- package/dist/js/types/attrBinding.d.ts.map +1 -0
- package/dist/js/types/binder.d.ts +67 -0
- package/dist/js/types/binder.d.ts.map +1 -0
- package/dist/js/types/changeBinding.d.ts +19 -0
- package/dist/js/types/changeBinding.d.ts.map +1 -0
- package/dist/js/types/commentWrapper.d.ts +39 -0
- package/dist/js/types/commentWrapper.d.ts.map +1 -0
- package/dist/js/types/config.d.ts +55 -0
- package/dist/js/types/config.d.ts.map +1 -0
- package/dist/js/types/createBindingOption.d.ts +32 -0
- package/dist/js/types/createBindingOption.d.ts.map +1 -0
- package/dist/js/types/createEventBinding.d.ts +10 -0
- package/dist/js/types/createEventBinding.d.ts.map +1 -0
- package/dist/js/types/cssBinding.d.ts +15 -0
- package/dist/js/types/cssBinding.d.ts.map +1 -0
- package/dist/js/types/domWalker.d.ts +9 -0
- package/dist/js/types/domWalker.d.ts.map +1 -0
- package/dist/js/types/forOfBinding.d.ts +12 -0
- package/dist/js/types/forOfBinding.d.ts.map +1 -0
- package/dist/js/types/hoverBinding.d.ts +13 -0
- package/dist/js/types/hoverBinding.d.ts.map +1 -0
- package/dist/js/types/ifBinding.d.ts +12 -0
- package/dist/js/types/ifBinding.d.ts.map +1 -0
- package/dist/js/types/index.d.ts +10 -0
- package/dist/js/types/index.d.ts.map +1 -0
- package/dist/js/types/modelBinding.d.ts +12 -0
- package/dist/js/types/modelBinding.d.ts.map +1 -0
- package/dist/js/types/postProcess.d.ts +3 -0
- package/dist/js/types/postProcess.d.ts.map +1 -0
- package/dist/js/types/pubSub.d.ts +11 -0
- package/dist/js/types/pubSub.d.ts.map +1 -0
- package/dist/js/types/reactiveProxy.d.ts +28 -0
- package/dist/js/types/reactiveProxy.d.ts.map +1 -0
- package/dist/js/types/renderForOfBinding.d.ts +8 -0
- package/dist/js/types/renderForOfBinding.d.ts.map +1 -0
- package/dist/js/types/renderIfBinding.d.ts +22 -0
- package/dist/js/types/renderIfBinding.d.ts.map +1 -0
- package/dist/js/types/renderIteration.d.ts +16 -0
- package/dist/js/types/renderIteration.d.ts.map +1 -0
- package/dist/js/types/renderTemplate.d.ts +14 -0
- package/dist/js/types/renderTemplate.d.ts.map +1 -0
- package/dist/js/types/renderTemplatesBinding.d.ts +19 -0
- package/dist/js/types/renderTemplatesBinding.d.ts.map +1 -0
- package/dist/js/types/showBinding.d.ts +13 -0
- package/dist/js/types/showBinding.d.ts.map +1 -0
- package/dist/js/types/switchBinding.d.ts +13 -0
- package/dist/js/types/switchBinding.d.ts.map +1 -0
- package/dist/js/types/textBinding.d.ts +13 -0
- package/dist/js/types/textBinding.d.ts.map +1 -0
- package/dist/js/types/types.d.ts +111 -0
- package/dist/js/types/types.d.ts.map +1 -0
- package/dist/js/types/util.d.ts +119 -0
- package/dist/js/types/util.d.ts.map +1 -0
- package/dist/js/types.d.ts +111 -0
- package/dist/js/types.d.ts.map +1 -0
- package/dist/js/util.d.ts +119 -0
- package/dist/js/util.d.ts.map +1 -0
- package/eslint.config.js +124 -0
- package/examples/DBMONSTER_COMPARISON.md +123 -0
- package/examples/afterRenderDemo.html +119 -0
- package/examples/bootstrap/css/animate.css +1579 -1579
- package/examples/bootstrap/css/bootstrap.min.css +6 -6
- package/examples/bootstrap/css/homeservices.css +378 -390
- package/examples/bootstrap/css/open-iconic.css +511 -511
- package/examples/bootstrap/fonts/open-iconic.svg +543 -543
- package/examples/bootstrap/js/compMessageDialog.js +20 -19
- package/examples/bootstrap/js/compSearchBar.js +12 -19
- package/examples/bootstrap/js/compSearchResults.js +50 -46
- package/examples/bootstrap/js/featureAdsResult.json +65 -65
- package/examples/bootstrap/js/searchResult.json +57 -57
- package/examples/bootstrap.html +343 -332
- package/examples/css/baseTodo.css +141 -141
- package/examples/css/dbMonsterStyles.css +27 -27
- package/examples/css/indexTodo.css +374 -374
- package/examples/dbmonsterForOfReactive.html +40 -0
- package/examples/dbmonsterReact.html +19 -0
- package/examples/forOfBindingSimpleDebug.html +45 -0
- package/examples/form.html +20 -4
- package/examples/globalConfig.html +131 -0
- package/examples/js/afterRenderDemo.js +190 -0
- package/examples/js/appTodo.js +46 -46
- package/examples/js/attrBindingDemo.js +2 -2
- package/examples/js/dbMonApp.js +24 -26
- package/examples/js/dbMonAppReact.jsx +79 -0
- package/examples/js/dbMonAppReactive.js +28 -0
- package/examples/js/fiberDemo.js +4 -4
- package/examples/js/filtersDemo.js +8 -8
- package/examples/js/forOfDemo.js +7 -9
- package/examples/js/forOfDemoComplex.js +44 -17
- package/examples/js/form.js +44 -12
- package/examples/js/globalConfig.js +117 -0
- package/examples/js/ifBindingDemo.js +16 -16
- package/examples/js/reactiveDemo.js +119 -0
- package/examples/js/switchBindingDemo.js +8 -8
- package/examples/react-dbmonster/dist/bundle.js +43 -0
- package/examples/react-dbmonster/package-lock.json +537 -0
- package/examples/react-dbmonster/package.json +16 -0
- package/examples/react-dbmonster/src/index.jsx +80 -0
- package/examples/reactiveDemo.html +127 -0
- package/examples/refreshRateTest.html +75 -75
- package/index.html +841 -0
- package/package.json +31 -34
- package/rollup.config.js +79 -36
- package/src/{_escape.js → _escape.ts} +19 -17
- package/src/applyBinding.ts +179 -0
- package/src/{attrBinding.js → attrBinding.ts} +14 -13
- package/src/binder.ts +289 -0
- package/src/changeBinding.ts +93 -0
- package/src/{commentWrapper.js → commentWrapper.ts} +33 -30
- package/src/config.ts +107 -0
- package/src/createBindingOption.ts +91 -0
- package/src/createEventBinding.ts +88 -0
- package/src/{cssBinding.js → cssBinding.ts} +13 -11
- package/src/{domWalker.js → domWalker.ts} +44 -30
- package/src/{forOfBinding.js → forOfBinding.ts} +4 -3
- package/src/hoverBinding.ts +84 -0
- package/src/{ifBinding.js → ifBinding.ts} +14 -12
- package/src/index.ts +53 -0
- package/src/{modelBinding.js → modelBinding.ts} +11 -9
- package/src/postProcess.ts +22 -0
- package/src/{pubSub.js → pubSub.ts} +24 -15
- package/src/reactiveProxy.ts +285 -0
- package/src/{renderForOfBinding.js → renderForOfBinding.ts} +55 -33
- package/src/{renderIfBinding.js → renderIfBinding.ts} +45 -20
- package/src/renderIteration.ts +53 -0
- package/src/renderTemplate.ts +165 -0
- package/src/renderTemplatesBinding.ts +73 -0
- package/src/{showBinding.js → showBinding.ts} +4 -3
- package/src/{switchBinding.js → switchBinding.ts} +18 -15
- package/src/{textBinding.js → textBinding.ts} +5 -4
- package/src/types.ts +124 -0
- package/src/util.ts +810 -0
- package/test/css/reporter.css +9 -9
- package/test/fixtures/dataBindBootstrap.html +2 -2
- package/test/fixtures/formBindings.html +9 -1
- package/test/globals.d.ts +19 -0
- package/test/helpers/testHelper.js +46 -11
- package/test/mocks/featureAdsResult.json +65 -65
- package/test/mocks/searchResult.json +57 -57
- package/test/specs/{attrBinding.spec.js → attrBinding.spec.ts} +103 -106
- package/test/specs/{binder.spec.js → binder.spec.ts} +29 -27
- package/test/specs/blurBinding.spec.ts +60 -0
- package/test/specs/chainableUse.spec.ts +125 -0
- package/test/specs/clickBinding.spec.ts +194 -0
- package/test/specs/{cssBinding.spec.js → cssBinding.spec.ts} +72 -79
- package/test/specs/{dataBindBootstrap.spec.js → dataBindBootstrap.spec.ts} +332 -313
- package/test/specs/{filter.spec.js → filter.spec.ts} +75 -76
- package/test/specs/{forOfBinding.spec.js → forOfBinding.spec.ts} +208 -219
- package/test/specs/formBinding.spec.ts +272 -0
- package/test/specs/ifBinding.spec.ts +165 -0
- package/test/specs/{nestedComponent.spec.js → nestedComponent.spec.ts} +88 -88
- package/test/specs/reactiveProxy.spec.ts +465 -0
- package/test/specs/{showBinding.spec.js → showBinding.spec.ts} +148 -149
- package/test/specs/{switchBinding.spec.js → switchBinding.spec.ts} +172 -173
- package/test/specs/templateBinding.spec.ts +273 -0
- package/test/specs/{textBinding.spec.js → textBinding.spec.ts} +47 -48
- package/test/tsconfig.json +31 -0
- package/test-output.txt +200 -0
- package/test-reactive.html +224 -0
- package/tsconfig.json +28 -0
- package/vendors/lodash.custom.js +4577 -4577
- package/vendors/lodash.custom.min.js +45 -45
- package/vitest.config.js +27 -0
- package/.eslintrc.js +0 -1
- package/.grunt/grunt-contrib-jasmine/boot.js +0 -161
- package/.grunt/grunt-contrib-jasmine/dist/js/dataBind.js +0 -9
- package/.grunt/grunt-contrib-jasmine/grunt-template-jasmine-istanbul/reporter.js +0 -23
- package/.grunt/grunt-contrib-jasmine/jasmine-html.js +0 -853
- package/.grunt/grunt-contrib-jasmine/jasmine.css +0 -271
- package/.grunt/grunt-contrib-jasmine/jasmine.js +0 -9761
- package/.grunt/grunt-contrib-jasmine/jasmine_favicon.png +0 -0
- package/.grunt/grunt-contrib-jasmine/json2.js +0 -489
- package/.grunt/grunt-contrib-jasmine/reporter.js +0 -107
- package/coverage/coverage.json +0 -1
- package/coverage/lcov/lcov-report/base.css +0 -213
- package/coverage/lcov/lcov-report/index.html +0 -93
- package/coverage/lcov/lcov-report/js/dataBind.js.html +0 -6596
- package/coverage/lcov/lcov-report/js/index.html +0 -93
- package/coverage/lcov/lcov-report/prettify.css +0 -1
- package/coverage/lcov/lcov-report/prettify.js +0 -1
- package/coverage/lcov/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov/lcov-report/sorter.js +0 -158
- package/coverage/lcov/lcov.info +0 -1991
- package/eslintrc.json +0 -40
- package/examples/bootstrap/js/bootstrap.min.js +0 -6
- package/examples/bootstrap/js/popper.min.js +0 -5
- package/examples/bootstrap/js/searchSuggestion.js +0 -58
- package/examples/bootstrap/js/typeahead.jquery.js +0 -1538
- package/gruntfile.js +0 -92
- package/gulpfile.js +0 -32
- package/src/binder.js +0 -422
- package/src/changeBinding.js +0 -57
- package/src/config.js +0 -65
- package/src/createBindingOption.js +0 -66
- package/src/createEventBinding.js +0 -46
- package/src/eventSystem.js +0 -46
- package/src/hoverBinding.js +0 -57
- package/src/index.js +0 -26
- package/src/renderTemplate.js +0 -128
- package/src/util.js +0 -648
- package/test/specs/blurBinding.spec.js +0 -57
- package/test/specs/formBinding.spec.js +0 -292
- package/test/specs/ifBinding.spec.js +0 -169
- package/test/specs/templateBinding.spec.js +0 -117
- package/vendors/jasmine-jquery.js +0 -841
- package/vendors/jquery-3.2.1.min.js +0 -4
|
@@ -1,841 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
|
|
3
|
-
|
|
4
|
-
Version 2.1.1
|
|
5
|
-
|
|
6
|
-
https://github.com/velesin/jasmine-jquery
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2010-2014 Wojciech Zawistowski, Travis Jeffery
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
11
|
-
a copy of this software and associated documentation files (the
|
|
12
|
-
"Software"), to deal in the Software without restriction, including
|
|
13
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
14
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
15
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
16
|
-
the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be
|
|
19
|
-
included in all copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
22
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
23
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
24
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
25
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
27
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
(function (root, factory) {
|
|
31
|
-
if (typeof module !== 'undefined' && module.exports && typeof exports !== 'undefined') {
|
|
32
|
-
factory(root, root.jasmine, require('jquery'));
|
|
33
|
-
} else {
|
|
34
|
-
factory(root, root.jasmine, root.jQuery);
|
|
35
|
-
}
|
|
36
|
-
}((function() {return this; })(), function (window, jasmine, $) { "use strict";
|
|
37
|
-
|
|
38
|
-
jasmine.spiedEventsKey = function (selector, eventName) {
|
|
39
|
-
return [$(selector).selector, eventName].toString()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
jasmine.getFixtures = function () {
|
|
43
|
-
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
jasmine.getStyleFixtures = function () {
|
|
47
|
-
return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
jasmine.Fixtures = function () {
|
|
51
|
-
this.containerId = 'jasmine-fixtures'
|
|
52
|
-
this.fixturesCache_ = {}
|
|
53
|
-
this.fixturesPath = 'spec/javascripts/fixtures'
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
jasmine.Fixtures.prototype.set = function (html) {
|
|
57
|
-
this.cleanUp()
|
|
58
|
-
return this.createContainer_(html)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
jasmine.Fixtures.prototype.appendSet= function (html) {
|
|
62
|
-
this.addToContainer_(html)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
jasmine.Fixtures.prototype.preload = function () {
|
|
66
|
-
this.read.apply(this, arguments)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
jasmine.Fixtures.prototype.load = function () {
|
|
70
|
-
this.cleanUp()
|
|
71
|
-
this.createContainer_(this.read.apply(this, arguments))
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
jasmine.Fixtures.prototype.appendLoad = function () {
|
|
75
|
-
this.addToContainer_(this.read.apply(this, arguments))
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
jasmine.Fixtures.prototype.read = function () {
|
|
79
|
-
var htmlChunks = []
|
|
80
|
-
, fixtureUrls = arguments
|
|
81
|
-
|
|
82
|
-
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
|
83
|
-
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return htmlChunks.join('')
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
jasmine.Fixtures.prototype.clearCache = function () {
|
|
90
|
-
this.fixturesCache_ = {}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
jasmine.Fixtures.prototype.cleanUp = function () {
|
|
94
|
-
$('#' + this.containerId).remove()
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
jasmine.Fixtures.prototype.sandbox = function (attributes) {
|
|
98
|
-
var attributesToSet = attributes || {}
|
|
99
|
-
return $('<div id="sandbox" />').attr(attributesToSet)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
jasmine.Fixtures.prototype.createContainer_ = function (html) {
|
|
103
|
-
var container = $('<div>')
|
|
104
|
-
.attr('id', this.containerId)
|
|
105
|
-
.html(html)
|
|
106
|
-
|
|
107
|
-
$(document.body).append(container)
|
|
108
|
-
return container
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
jasmine.Fixtures.prototype.addToContainer_ = function (html){
|
|
112
|
-
var container = $(document.body).find('#'+this.containerId).append(html)
|
|
113
|
-
|
|
114
|
-
if (!container.length) {
|
|
115
|
-
this.createContainer_(html)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) {
|
|
120
|
-
if (typeof this.fixturesCache_[url] === 'undefined') {
|
|
121
|
-
this.loadFixtureIntoCache_(url)
|
|
122
|
-
}
|
|
123
|
-
return this.fixturesCache_[url]
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
|
|
127
|
-
var self = this
|
|
128
|
-
, url = this.makeFixtureUrl_(relativeUrl)
|
|
129
|
-
, htmlText = ''
|
|
130
|
-
, request = $.ajax({
|
|
131
|
-
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
|
132
|
-
cache: false,
|
|
133
|
-
url: url,
|
|
134
|
-
dataType: 'html',
|
|
135
|
-
success: function (data, status, $xhr) {
|
|
136
|
-
htmlText = $xhr.responseText
|
|
137
|
-
}
|
|
138
|
-
}).fail(function ($xhr, status, err) {
|
|
139
|
-
throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || [];
|
|
143
|
-
|
|
144
|
-
scripts.each(function(){
|
|
145
|
-
$.ajax({
|
|
146
|
-
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
|
147
|
-
cache: false,
|
|
148
|
-
dataType: 'script',
|
|
149
|
-
url: $(this).attr('src'),
|
|
150
|
-
success: function (data, status, $xhr) {
|
|
151
|
-
htmlText += '<script>' + $xhr.responseText + '</script>'
|
|
152
|
-
},
|
|
153
|
-
error: function ($xhr, status, err) {
|
|
154
|
-
throw new Error('Script could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
self.fixturesCache_[relativeUrl] = htmlText;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){
|
|
163
|
-
return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
|
|
167
|
-
return this[methodName].apply(this, passedArguments)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
jasmine.StyleFixtures = function () {
|
|
172
|
-
this.fixturesCache_ = {}
|
|
173
|
-
this.fixturesNodes_ = []
|
|
174
|
-
this.fixturesPath = 'spec/javascripts/fixtures'
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
jasmine.StyleFixtures.prototype.set = function (css) {
|
|
178
|
-
this.cleanUp()
|
|
179
|
-
this.createStyle_(css)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
jasmine.StyleFixtures.prototype.appendSet = function (css) {
|
|
183
|
-
this.createStyle_(css)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
jasmine.StyleFixtures.prototype.preload = function () {
|
|
187
|
-
this.read_.apply(this, arguments)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
jasmine.StyleFixtures.prototype.load = function () {
|
|
191
|
-
this.cleanUp()
|
|
192
|
-
this.createStyle_(this.read_.apply(this, arguments))
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
jasmine.StyleFixtures.prototype.appendLoad = function () {
|
|
196
|
-
this.createStyle_(this.read_.apply(this, arguments))
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
jasmine.StyleFixtures.prototype.cleanUp = function () {
|
|
200
|
-
while(this.fixturesNodes_.length) {
|
|
201
|
-
this.fixturesNodes_.pop().remove()
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
jasmine.StyleFixtures.prototype.createStyle_ = function (html) {
|
|
206
|
-
var styleText = $('<div></div>').html(html).text()
|
|
207
|
-
, style = $('<style>' + styleText + '</style>')
|
|
208
|
-
|
|
209
|
-
this.fixturesNodes_.push(style)
|
|
210
|
-
$('head').append(style)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
|
|
214
|
-
jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
|
|
215
|
-
jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
|
|
216
|
-
jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
|
|
217
|
-
jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
|
|
218
|
-
jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
|
|
219
|
-
|
|
220
|
-
jasmine.getJSONFixtures = function () {
|
|
221
|
-
return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
jasmine.JSONFixtures = function () {
|
|
225
|
-
this.fixturesCache_ = {}
|
|
226
|
-
this.fixturesPath = 'spec/javascripts/fixtures/json'
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
jasmine.JSONFixtures.prototype.load = function () {
|
|
230
|
-
this.read.apply(this, arguments)
|
|
231
|
-
return this.fixturesCache_
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
jasmine.JSONFixtures.prototype.read = function () {
|
|
235
|
-
var fixtureUrls = arguments
|
|
236
|
-
|
|
237
|
-
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
|
238
|
-
this.getFixtureData_(fixtureUrls[urlIndex])
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return this.fixturesCache_
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
jasmine.JSONFixtures.prototype.clearCache = function () {
|
|
245
|
-
this.fixturesCache_ = {}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) {
|
|
249
|
-
if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url)
|
|
250
|
-
return this.fixturesCache_[url]
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
|
|
254
|
-
var self = this
|
|
255
|
-
, url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
|
256
|
-
|
|
257
|
-
$.ajax({
|
|
258
|
-
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
|
259
|
-
cache: false,
|
|
260
|
-
dataType: 'json',
|
|
261
|
-
url: url,
|
|
262
|
-
success: function (data) {
|
|
263
|
-
self.fixturesCache_[relativeUrl] = data
|
|
264
|
-
},
|
|
265
|
-
error: function ($xhr, status, err) {
|
|
266
|
-
throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
|
|
267
|
-
}
|
|
268
|
-
})
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
|
|
272
|
-
return this[methodName].apply(this, passedArguments)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
jasmine.jQuery = function () {}
|
|
276
|
-
|
|
277
|
-
jasmine.jQuery.browserTagCaseIndependentHtml = function (html) {
|
|
278
|
-
return $('<div/>').append(html).html()
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
jasmine.jQuery.elementToString = function (element) {
|
|
282
|
-
return $(element).map(function () { return this.outerHTML; }).toArray().join(', ')
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
var data = {
|
|
286
|
-
spiedEvents: {}
|
|
287
|
-
, handlers: []
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
jasmine.jQuery.events = {
|
|
291
|
-
spyOn: function (selector, eventName) {
|
|
292
|
-
var handler = function (e) {
|
|
293
|
-
var calls = (typeof data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] !== 'undefined') ? data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0
|
|
294
|
-
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = {
|
|
295
|
-
args: jasmine.util.argsToArray(arguments),
|
|
296
|
-
calls: ++calls
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
$(selector).on(eventName, handler)
|
|
301
|
-
data.handlers.push(handler)
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
selector: selector,
|
|
305
|
-
eventName: eventName,
|
|
306
|
-
handler: handler,
|
|
307
|
-
reset: function (){
|
|
308
|
-
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
|
309
|
-
},
|
|
310
|
-
calls: {
|
|
311
|
-
count: function () {
|
|
312
|
-
return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ?
|
|
313
|
-
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0;
|
|
314
|
-
},
|
|
315
|
-
any: function () {
|
|
316
|
-
return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ?
|
|
317
|
-
!!data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : false;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
args: function (selector, eventName) {
|
|
324
|
-
var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].args
|
|
325
|
-
|
|
326
|
-
if (!actualArgs) {
|
|
327
|
-
throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
return actualArgs
|
|
331
|
-
},
|
|
332
|
-
|
|
333
|
-
wasTriggered: function (selector, eventName) {
|
|
334
|
-
return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
|
|
335
|
-
},
|
|
336
|
-
|
|
337
|
-
wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) {
|
|
338
|
-
var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1)
|
|
339
|
-
|
|
340
|
-
if (Object.prototype.toString.call(expectedArgs) !== '[object Array]')
|
|
341
|
-
actualArgs = actualArgs[0]
|
|
342
|
-
|
|
343
|
-
return util.equals(actualArgs, expectedArgs, customEqualityTesters)
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
wasPrevented: function (selector, eventName) {
|
|
347
|
-
var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
|
348
|
-
, args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args
|
|
349
|
-
, e = args ? args[0] : undefined
|
|
350
|
-
|
|
351
|
-
return e && e.isDefaultPrevented()
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
wasStopped: function (selector, eventName) {
|
|
355
|
-
var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
|
356
|
-
, args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args
|
|
357
|
-
, e = args ? args[0] : undefined
|
|
358
|
-
|
|
359
|
-
return e && e.isPropagationStopped()
|
|
360
|
-
},
|
|
361
|
-
|
|
362
|
-
cleanUp: function () {
|
|
363
|
-
data.spiedEvents = {}
|
|
364
|
-
data.handlers = []
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
var hasProperty = function (actualValue, expectedValue) {
|
|
369
|
-
if (expectedValue === undefined)
|
|
370
|
-
return actualValue !== undefined
|
|
371
|
-
|
|
372
|
-
return actualValue === expectedValue
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
beforeEach(function () {
|
|
376
|
-
jasmine.addMatchers({
|
|
377
|
-
toHaveClass: function () {
|
|
378
|
-
return {
|
|
379
|
-
compare: function (actual, className) {
|
|
380
|
-
return { pass: $(actual).hasClass(className) }
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
toHaveCss: function () {
|
|
386
|
-
return {
|
|
387
|
-
compare: function (actual, css) {
|
|
388
|
-
var stripCharsRegex = /[\s;\"\']/g
|
|
389
|
-
for (var prop in css) {
|
|
390
|
-
var value = css[prop]
|
|
391
|
-
// see issue #147 on gh
|
|
392
|
-
;if ((value === 'auto') && ($(actual).get(0).style[prop] === 'auto')) continue
|
|
393
|
-
var actualStripped = $(actual).css(prop).replace(stripCharsRegex, '')
|
|
394
|
-
var valueStripped = value.replace(stripCharsRegex, '')
|
|
395
|
-
if (actualStripped !== valueStripped) return { pass: false }
|
|
396
|
-
}
|
|
397
|
-
return { pass: true }
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
|
|
402
|
-
toBeVisible: function () {
|
|
403
|
-
return {
|
|
404
|
-
compare: function (actual) {
|
|
405
|
-
return { pass: $(actual).is(':visible') }
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
toBeHidden: function () {
|
|
411
|
-
return {
|
|
412
|
-
compare: function (actual) {
|
|
413
|
-
return { pass: $(actual).is(':hidden') }
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
toBeSelected: function () {
|
|
419
|
-
return {
|
|
420
|
-
compare: function (actual) {
|
|
421
|
-
return { pass: $(actual).is(':selected') }
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
toBeChecked: function () {
|
|
427
|
-
return {
|
|
428
|
-
compare: function (actual) {
|
|
429
|
-
return { pass: $(actual).is(':checked') }
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
|
|
434
|
-
toBeEmpty: function () {
|
|
435
|
-
return {
|
|
436
|
-
compare: function (actual) {
|
|
437
|
-
return { pass: $(actual).is(':empty') }
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
-
toBeInDOM: function () {
|
|
443
|
-
return {
|
|
444
|
-
compare: function (actual) {
|
|
445
|
-
return { pass: $.contains(document.documentElement, $(actual)[0]) }
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
toExist: function () {
|
|
451
|
-
return {
|
|
452
|
-
compare: function (actual) {
|
|
453
|
-
return { pass: $(actual).length }
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
toHaveLength: function () {
|
|
459
|
-
return {
|
|
460
|
-
compare: function (actual, length) {
|
|
461
|
-
return { pass: $(actual).length === length }
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
},
|
|
465
|
-
|
|
466
|
-
toHaveAttr: function () {
|
|
467
|
-
return {
|
|
468
|
-
compare: function (actual, attributeName, expectedAttributeValue) {
|
|
469
|
-
return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) }
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
|
|
474
|
-
toHaveProp: function () {
|
|
475
|
-
return {
|
|
476
|
-
compare: function (actual, propertyName, expectedPropertyValue) {
|
|
477
|
-
return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) }
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
|
|
482
|
-
toHaveId: function () {
|
|
483
|
-
return {
|
|
484
|
-
compare: function (actual, id) {
|
|
485
|
-
return { pass: $(actual).attr('id') == id }
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
|
|
490
|
-
toHaveHtml: function () {
|
|
491
|
-
return {
|
|
492
|
-
compare: function (actual, html) {
|
|
493
|
-
return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) }
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
},
|
|
497
|
-
|
|
498
|
-
toContainHtml: function () {
|
|
499
|
-
return {
|
|
500
|
-
compare: function (actual, html) {
|
|
501
|
-
var actualHtml = $(actual).html()
|
|
502
|
-
, expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html)
|
|
503
|
-
|
|
504
|
-
return { pass: (actualHtml.indexOf(expectedHtml) >= 0) }
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
},
|
|
508
|
-
|
|
509
|
-
toHaveText: function () {
|
|
510
|
-
return {
|
|
511
|
-
compare: function (actual, text) {
|
|
512
|
-
var actualText = $(actual).text()
|
|
513
|
-
var trimmedText = $.trim(actualText)
|
|
514
|
-
|
|
515
|
-
if (text && $.isFunction(text.test)) {
|
|
516
|
-
return { pass: text.test(actualText) || text.test(trimmedText) }
|
|
517
|
-
} else {
|
|
518
|
-
return { pass: (actualText == text || trimmedText == text) }
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
|
|
524
|
-
toContainText: function () {
|
|
525
|
-
return {
|
|
526
|
-
compare: function (actual, text) {
|
|
527
|
-
var trimmedText = $.trim($(actual).text())
|
|
528
|
-
|
|
529
|
-
if (text && $.isFunction(text.test)) {
|
|
530
|
-
return { pass: text.test(trimmedText) }
|
|
531
|
-
} else {
|
|
532
|
-
return { pass: trimmedText.indexOf(text) != -1 }
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
},
|
|
537
|
-
|
|
538
|
-
toHaveValue: function () {
|
|
539
|
-
return {
|
|
540
|
-
compare: function (actual, value) {
|
|
541
|
-
return { pass: $(actual).val() === value }
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
},
|
|
545
|
-
|
|
546
|
-
toHaveData: function () {
|
|
547
|
-
return {
|
|
548
|
-
compare: function (actual, key, expectedValue) {
|
|
549
|
-
return { pass: hasProperty($(actual).data(key), expectedValue) }
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
},
|
|
553
|
-
|
|
554
|
-
toContainElement: function () {
|
|
555
|
-
return {
|
|
556
|
-
compare: function (actual, selector) {
|
|
557
|
-
return { pass: $(actual).find(selector).length }
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
},
|
|
561
|
-
|
|
562
|
-
toBeMatchedBy: function () {
|
|
563
|
-
return {
|
|
564
|
-
compare: function (actual, selector) {
|
|
565
|
-
return { pass: $(actual).filter(selector).length }
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
|
|
570
|
-
toBeDisabled: function () {
|
|
571
|
-
return {
|
|
572
|
-
compare: function (actual, selector) {
|
|
573
|
-
return { pass: $(actual).is(':disabled') }
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
},
|
|
577
|
-
|
|
578
|
-
toBeFocused: function (selector) {
|
|
579
|
-
return {
|
|
580
|
-
compare: function (actual, selector) {
|
|
581
|
-
return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement }
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
|
|
586
|
-
toHandle: function () {
|
|
587
|
-
return {
|
|
588
|
-
compare: function (actual, event) {
|
|
589
|
-
if ( !actual || actual.length === 0 ) return { pass: false };
|
|
590
|
-
var events = $._data($(actual).get(0), "events")
|
|
591
|
-
|
|
592
|
-
if (!events || !event || typeof event !== "string") {
|
|
593
|
-
return { pass: false }
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
var namespaces = event.split(".")
|
|
597
|
-
, eventType = namespaces.shift()
|
|
598
|
-
, sortedNamespaces = namespaces.slice(0).sort()
|
|
599
|
-
, namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
|
|
600
|
-
|
|
601
|
-
if (events[eventType] && namespaces.length) {
|
|
602
|
-
for (var i = 0; i < events[eventType].length; i++) {
|
|
603
|
-
var namespace = events[eventType][i].namespace
|
|
604
|
-
|
|
605
|
-
if (namespaceRegExp.test(namespace))
|
|
606
|
-
return { pass: true }
|
|
607
|
-
}
|
|
608
|
-
} else {
|
|
609
|
-
return { pass: (events[eventType] && events[eventType].length > 0) }
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
return { pass: false }
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
},
|
|
616
|
-
|
|
617
|
-
toHandleWith: function () {
|
|
618
|
-
return {
|
|
619
|
-
compare: function (actual, eventName, eventHandler) {
|
|
620
|
-
if ( !actual || actual.length === 0 ) return { pass: false };
|
|
621
|
-
var normalizedEventName = eventName.split('.')[0]
|
|
622
|
-
, stack = $._data($(actual).get(0), "events")[normalizedEventName]
|
|
623
|
-
|
|
624
|
-
for (var i = 0; i < stack.length; i++) {
|
|
625
|
-
if (stack[i].handler == eventHandler) return { pass: true }
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
return { pass: false }
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
},
|
|
632
|
-
|
|
633
|
-
toHaveBeenTriggeredOn: function () {
|
|
634
|
-
return {
|
|
635
|
-
compare: function (actual, selector) {
|
|
636
|
-
var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) }
|
|
637
|
-
|
|
638
|
-
result.message = result.pass ?
|
|
639
|
-
"Expected event " + $(actual) + " not to have been triggered on " + selector :
|
|
640
|
-
"Expected event " + $(actual) + " to have been triggered on " + selector
|
|
641
|
-
|
|
642
|
-
return result;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
|
|
647
|
-
toHaveBeenTriggered: function (){
|
|
648
|
-
return {
|
|
649
|
-
compare: function (actual) {
|
|
650
|
-
var eventName = actual.eventName
|
|
651
|
-
, selector = actual.selector
|
|
652
|
-
, result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) }
|
|
653
|
-
|
|
654
|
-
result.message = result.pass ?
|
|
655
|
-
"Expected event " + eventName + " not to have been triggered on " + selector :
|
|
656
|
-
"Expected event " + eventName + " to have been triggered on " + selector
|
|
657
|
-
|
|
658
|
-
return result
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
|
|
663
|
-
toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) {
|
|
664
|
-
return {
|
|
665
|
-
compare: function (actual, selector, expectedArgs) {
|
|
666
|
-
var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual)
|
|
667
|
-
, result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) }
|
|
668
|
-
|
|
669
|
-
if (wasTriggered) {
|
|
670
|
-
var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1]
|
|
671
|
-
result.message = result.pass ?
|
|
672
|
-
"Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) :
|
|
673
|
-
"Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
|
|
674
|
-
|
|
675
|
-
} else {
|
|
676
|
-
// todo check on this
|
|
677
|
-
result.message = result.pass ?
|
|
678
|
-
"Expected event " + actual + " not to have been triggered on " + selector :
|
|
679
|
-
"Expected event " + actual + " to have been triggered on " + selector
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
return result
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
},
|
|
686
|
-
|
|
687
|
-
toHaveBeenPreventedOn: function () {
|
|
688
|
-
return {
|
|
689
|
-
compare: function (actual, selector) {
|
|
690
|
-
var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) }
|
|
691
|
-
|
|
692
|
-
result.message = result.pass ?
|
|
693
|
-
"Expected event " + actual + " not to have been prevented on " + selector :
|
|
694
|
-
"Expected event " + actual + " to have been prevented on " + selector
|
|
695
|
-
|
|
696
|
-
return result
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
},
|
|
700
|
-
|
|
701
|
-
toHaveBeenPrevented: function () {
|
|
702
|
-
return {
|
|
703
|
-
compare: function (actual) {
|
|
704
|
-
var eventName = actual.eventName
|
|
705
|
-
, selector = actual.selector
|
|
706
|
-
, result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) }
|
|
707
|
-
|
|
708
|
-
result.message = result.pass ?
|
|
709
|
-
"Expected event " + eventName + " not to have been prevented on " + selector :
|
|
710
|
-
"Expected event " + eventName + " to have been prevented on " + selector
|
|
711
|
-
|
|
712
|
-
return result
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
|
|
717
|
-
toHaveBeenStoppedOn: function () {
|
|
718
|
-
return {
|
|
719
|
-
compare: function (actual, selector) {
|
|
720
|
-
var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) }
|
|
721
|
-
|
|
722
|
-
result.message = result.pass ?
|
|
723
|
-
"Expected event " + actual + " not to have been stopped on " + selector :
|
|
724
|
-
"Expected event " + actual + " to have been stopped on " + selector
|
|
725
|
-
|
|
726
|
-
return result;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
},
|
|
730
|
-
|
|
731
|
-
toHaveBeenStopped: function () {
|
|
732
|
-
return {
|
|
733
|
-
compare: function (actual) {
|
|
734
|
-
var eventName = actual.eventName
|
|
735
|
-
, selector = actual.selector
|
|
736
|
-
, result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) }
|
|
737
|
-
|
|
738
|
-
result.message = result.pass ?
|
|
739
|
-
"Expected event " + eventName + " not to have been stopped on " + selector :
|
|
740
|
-
"Expected event " + eventName + " to have been stopped on " + selector
|
|
741
|
-
|
|
742
|
-
return result
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
})
|
|
747
|
-
|
|
748
|
-
jasmine.getEnv().addCustomEqualityTester(function(a, b) {
|
|
749
|
-
if (a && b) {
|
|
750
|
-
if (a instanceof $ || jasmine.isDomNode(a)) {
|
|
751
|
-
var $a = $(a)
|
|
752
|
-
|
|
753
|
-
if (b instanceof $)
|
|
754
|
-
return $a.length == b.length && $a.is(b)
|
|
755
|
-
|
|
756
|
-
return $a.is(b);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
if (b instanceof $ || jasmine.isDomNode(b)) {
|
|
760
|
-
var $b = $(b)
|
|
761
|
-
|
|
762
|
-
if (a instanceof $)
|
|
763
|
-
return a.length == $b.length && $b.is(a)
|
|
764
|
-
|
|
765
|
-
return $b.is(a);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
})
|
|
769
|
-
|
|
770
|
-
jasmine.getEnv().addCustomEqualityTester(function (a, b) {
|
|
771
|
-
if (a instanceof $ && b instanceof $ && a.size() == b.size())
|
|
772
|
-
return a.is(b)
|
|
773
|
-
})
|
|
774
|
-
})
|
|
775
|
-
|
|
776
|
-
afterEach(function () {
|
|
777
|
-
jasmine.getFixtures().cleanUp()
|
|
778
|
-
jasmine.getStyleFixtures().cleanUp()
|
|
779
|
-
jasmine.jQuery.events.cleanUp()
|
|
780
|
-
})
|
|
781
|
-
|
|
782
|
-
window.readFixtures = function () {
|
|
783
|
-
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
window.preloadFixtures = function () {
|
|
787
|
-
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
window.loadFixtures = function () {
|
|
791
|
-
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
window.appendLoadFixtures = function () {
|
|
795
|
-
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
window.setFixtures = function (html) {
|
|
799
|
-
return jasmine.getFixtures().proxyCallTo_('set', arguments)
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
window.appendSetFixtures = function () {
|
|
803
|
-
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
window.sandbox = function (attributes) {
|
|
807
|
-
return jasmine.getFixtures().sandbox(attributes)
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
window.spyOnEvent = function (selector, eventName) {
|
|
811
|
-
return jasmine.jQuery.events.spyOn(selector, eventName)
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
window.preloadStyleFixtures = function () {
|
|
815
|
-
jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
window.loadStyleFixtures = function () {
|
|
819
|
-
jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
window.appendLoadStyleFixtures = function () {
|
|
823
|
-
jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
window.setStyleFixtures = function (html) {
|
|
827
|
-
jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
window.appendSetStyleFixtures = function (html) {
|
|
831
|
-
jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
window.loadJSONFixtures = function () {
|
|
835
|
-
return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
window.getJSONFixture = function (url) {
|
|
839
|
-
return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
|
|
840
|
-
}
|
|
841
|
-
}));
|