joosy 0.1.0.alpha → 1.0.0.RC1
Sign up to get free protection for your applications and to get access to all the features.
- data/.codoopts +5 -0
- data/.gitignore +2 -0
- data/Gemfile +15 -2
- data/Gemfile.lock +102 -81
- data/Guardfile +16 -16
- data/LICENSE +22 -0
- data/MIT-LICENSE +2 -2
- data/README.md +118 -0
- data/app/assets/javascripts/joosy/core/application.js.coffee +53 -0
- data/app/assets/javascripts/joosy/core/form.js.coffee +338 -0
- data/app/assets/javascripts/joosy/core/helpers/form.js.coffee +72 -0
- data/app/assets/javascripts/joosy/core/helpers/view.js.coffee +42 -0
- data/app/assets/javascripts/joosy/core/helpers/widgets.js.coffee +14 -0
- data/app/assets/javascripts/joosy/core/joosy.js.coffee +184 -0
- data/app/assets/javascripts/joosy/core/layout.js.coffee +168 -0
- data/app/assets/javascripts/joosy/core/modules/container.js.coffee +124 -0
- data/app/assets/javascripts/joosy/core/modules/events.js.coffee +122 -0
- data/app/assets/javascripts/joosy/core/modules/filters.js.coffee +39 -0
- data/app/assets/javascripts/joosy/core/modules/log.js.coffee +36 -0
- data/app/assets/javascripts/joosy/core/modules/module.js.coffee +117 -0
- data/app/assets/javascripts/joosy/core/modules/renderer.js.coffee +200 -0
- data/app/assets/javascripts/joosy/core/modules/time_manager.js.coffee +46 -0
- data/app/assets/javascripts/joosy/core/modules/widgets_manager.js.coffee +87 -0
- data/app/assets/javascripts/joosy/core/page.js.coffee +387 -0
- data/app/assets/javascripts/joosy/core/preloader.js.coffee +13 -0
- data/app/assets/javascripts/joosy/core/resource/collection.js.coffee +175 -0
- data/app/assets/javascripts/joosy/core/resource/generic.js.coffee +303 -0
- data/app/assets/javascripts/joosy/core/resource/rest.js.coffee +244 -0
- data/app/assets/javascripts/joosy/core/resource/rest_collection.js.coffee +24 -0
- data/app/assets/javascripts/joosy/core/router.js.coffee +201 -0
- data/app/assets/javascripts/joosy/core/templaters/rails_jst.js.coffee +37 -0
- data/app/assets/javascripts/joosy/core/widget.js.coffee +85 -0
- data/app/assets/javascripts/joosy/preloaders/caching.js.coffee +169 -0
- data/app/assets/javascripts/joosy/preloaders/inline.js.coffee +56 -0
- data/{vendor → app}/assets/javascripts/joosy.js.coffee +0 -1
- data/app/helpers/joosy/sprockets_helper.rb +39 -12
- data/joosy.gemspec +4 -3
- data/lib/joosy/rails/engine.rb +12 -1
- data/lib/joosy/rails/version.rb +2 -2
- data/lib/joosy.rb +9 -0
- data/lib/rails/generators/joosy/application_generator.rb +15 -3
- data/lib/rails/generators/joosy/joosy_base.rb +2 -2
- data/lib/rails/generators/joosy/layout_generator.rb +8 -1
- data/lib/rails/generators/joosy/page_generator.rb +21 -6
- data/lib/rails/generators/joosy/preloader_generator.rb +14 -7
- data/lib/rails/generators/joosy/resource_generator.rb +29 -0
- data/lib/rails/generators/joosy/templates/app/helpers/application.js.coffee +4 -0
- data/lib/rails/generators/joosy/templates/app/layouts/application.js.coffee +1 -0
- data/lib/rails/generators/joosy/templates/app/layouts/template.js.coffee +1 -1
- data/lib/rails/generators/joosy/templates/app/pages/application.js.coffee +1 -1
- data/lib/rails/generators/joosy/templates/app/pages/template.js.coffee +3 -3
- data/lib/rails/generators/joosy/templates/app/pages/welcome/index.js.coffee +22 -0
- data/lib/rails/generators/joosy/templates/app/resources/template.js.coffee +2 -0
- data/lib/rails/generators/joosy/templates/app/routes.js.coffee +7 -1
- data/lib/rails/generators/joosy/templates/app/templates/layouts/application.jst.hamlc +2 -0
- data/lib/rails/generators/joosy/templates/app/templates/pages/welcome/index.jst.hamlc +7 -0
- data/lib/rails/generators/joosy/templates/app/widgets/template.js.coffee +2 -2
- data/lib/rails/generators/joosy/templates/app.js.coffee +4 -0
- data/lib/rails/generators/joosy/templates/app_preloader.js.coffee.erb +9 -12
- data/lib/rails/generators/joosy/templates/app_resources_predefiner.js.coffee.erb +11 -0
- data/lib/rails/generators/joosy/templates/preload.html.erb +5 -6
- data/lib/rails/generators/joosy/templates/preload.html.haml +3 -5
- data/lib/rails/generators/joosy/widget_generator.rb +8 -1
- data/lib/rails/resources_with_joosy.rb +11 -0
- data/spec/javascripts/helpers/spec_helper.js.coffee +25 -0
- data/spec/javascripts/joosy/core/application_spec.js.coffee +40 -0
- data/spec/javascripts/joosy/core/form_spec.js.coffee +200 -0
- data/spec/javascripts/joosy/core/helpers/forms_spec.js.coffee +103 -0
- data/spec/javascripts/joosy/core/helpers/view_spec.js.coffee +10 -0
- data/spec/javascripts/joosy/core/joosy_spec.js.coffee +97 -0
- data/spec/javascripts/joosy/core/layout_spec.js.coffee +50 -0
- data/spec/javascripts/joosy/core/modules/container_spec.js.coffee +32 -27
- data/spec/javascripts/joosy/core/modules/events_spec.js.coffee +55 -18
- data/spec/javascripts/joosy/core/modules/filters_spec.js.coffee +28 -27
- data/spec/javascripts/joosy/core/modules/log_spec.js.coffee +3 -3
- data/spec/javascripts/joosy/core/modules/module_spec.js.coffee +6 -15
- data/spec/javascripts/joosy/core/modules/renderer_spec.js.coffee +203 -0
- data/spec/javascripts/joosy/core/modules/time_manager_spec.js.coffee +12 -7
- data/spec/javascripts/joosy/core/modules/widget_manager_spec.js.coffee +31 -17
- data/spec/javascripts/joosy/core/page_spec.js.coffee +178 -0
- data/spec/javascripts/joosy/core/resource/collection_spec.js.coffee +84 -0
- data/spec/javascripts/joosy/core/resource/generic_spec.js.coffee +149 -0
- data/spec/javascripts/joosy/core/resource/rest_collection_spec.js.coffee +31 -0
- data/spec/javascripts/joosy/core/resource/rest_spec.js.coffee +171 -0
- data/spec/javascripts/joosy/core/router_spec.js.coffee +143 -0
- data/spec/javascripts/joosy/core/templaters/rails_jst_spec.js.coffee +25 -0
- data/spec/javascripts/joosy/core/widget_spec.js.coffee +40 -0
- data/spec/javascripts/joosy/preloaders/caching_spec.js.coffee +36 -0
- data/spec/javascripts/joosy/preloaders/inline_spec.js.coffee +16 -0
- data/spec/javascripts/support/assets/coolface.jpg +0 -0
- data/spec/javascripts/support/assets/okay.jpg +0 -0
- data/spec/javascripts/support/assets/test.js +1 -0
- data/spec/javascripts/support/sinon-ie-1.3.1.js +82 -0
- data/vendor/assets/javascripts/jquery.form.js +978 -963
- data/vendor/assets/javascripts/metamorph.js +409 -0
- data/vendor/assets/javascripts/sugar.js +1057 -366
- metadata +95 -50
- data/README.rdoc +0 -3
- data/lib/joosy/forms.rb +0 -47
- data/lib/joosy-rails.rb +0 -5
- data/lib/rails/generators/joosy/templates/preload.html.slim +0 -21
- data/tmp/javascripts/.gitignore +0 -1
- data/tmp/spec/javascripts/helpers/.gitignore +0 -1
- data/vendor/assets/javascripts/base64.js +0 -135
- data/vendor/assets/javascripts/inflection.js +0 -656
- data/vendor/assets/javascripts/joosy/core/application.js.coffee +0 -26
- data/vendor/assets/javascripts/joosy/core/form.js.coffee +0 -87
- data/vendor/assets/javascripts/joosy/core/joosy.js.coffee +0 -62
- data/vendor/assets/javascripts/joosy/core/layout.js.coffee +0 -38
- data/vendor/assets/javascripts/joosy/core/modules/container.js.coffee +0 -51
- data/vendor/assets/javascripts/joosy/core/modules/events.js.coffee +0 -17
- data/vendor/assets/javascripts/joosy/core/modules/filters.js.coffee +0 -39
- data/vendor/assets/javascripts/joosy/core/modules/log.js.coffee +0 -12
- data/vendor/assets/javascripts/joosy/core/modules/module.js.coffee +0 -28
- data/vendor/assets/javascripts/joosy/core/modules/time_manager.js.coffee +0 -23
- data/vendor/assets/javascripts/joosy/core/modules/widgets_manager.js.coffee +0 -45
- data/vendor/assets/javascripts/joosy/core/page.js.coffee +0 -136
- data/vendor/assets/javascripts/joosy/core/resource/rest.js.coffee +0 -69
- data/vendor/assets/javascripts/joosy/core/resource/rest_collection.js.coffee +0 -42
- data/vendor/assets/javascripts/joosy/core/router.js.coffee +0 -75
- data/vendor/assets/javascripts/joosy/core/widget.js.coffee +0 -35
- data/vendor/assets/javascripts/joosy/preloader/development.js.coffee +0 -27
- data/vendor/assets/javascripts/joosy/preloader/production.js.coffee +0 -84
@@ -0,0 +1,143 @@
|
|
1
|
+
describe "Joosy.Router", ->
|
2
|
+
|
3
|
+
class TestPage extends Joosy.Page
|
4
|
+
|
5
|
+
spies =
|
6
|
+
root: sinon.spy()
|
7
|
+
section: sinon.spy()
|
8
|
+
wildcard: sinon.spy()
|
9
|
+
|
10
|
+
map = Object.extended
|
11
|
+
'/': spies.root
|
12
|
+
'/page': TestPage
|
13
|
+
'/section':
|
14
|
+
'/page/:id': spies.section
|
15
|
+
'/page2/:more': TestPage
|
16
|
+
404: spies.wildcard
|
17
|
+
|
18
|
+
beforeEach ->
|
19
|
+
Joosy.Router.reset()
|
20
|
+
|
21
|
+
afterEach ->
|
22
|
+
$(window).unbind 'hashchange'
|
23
|
+
|
24
|
+
it "should map", ->
|
25
|
+
Joosy.Router.map map
|
26
|
+
expect(Joosy.Router.rawRoutes).toEqual map
|
27
|
+
|
28
|
+
it "should initialize on setup", ->
|
29
|
+
sinon.stub Joosy.Router, '__prepareRoutes'
|
30
|
+
sinon.stub Joosy.Router, '__respondRoute'
|
31
|
+
|
32
|
+
Joosy.Router.map map
|
33
|
+
Joosy.Router.__setupRoutes()
|
34
|
+
expect(Joosy.Router.__prepareRoutes.callCount).toEqual 1
|
35
|
+
expect(Joosy.Router.__prepareRoutes.args[0][0]).toEqual map
|
36
|
+
expect(Joosy.Router.__respondRoute.callCount).toEqual 1
|
37
|
+
expect(Joosy.Router.__respondRoute.args[0][0]).toEqual location.hash
|
38
|
+
Joosy.Router.__prepareRoutes.restore()
|
39
|
+
Joosy.Router.__respondRoute.restore()
|
40
|
+
|
41
|
+
it "should prepare route", ->
|
42
|
+
route = Joosy.Router.__prepareRoute "/such/a/long/long/url/:with/:plenty/:of/:params", "123"
|
43
|
+
|
44
|
+
expect(route).toEqual Object.extended
|
45
|
+
'^/?such/a/long/long/url/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$':
|
46
|
+
capture: ['with', 'plenty', 'of', 'params']
|
47
|
+
action: "123"
|
48
|
+
|
49
|
+
it "should cook routes", ->
|
50
|
+
sinon.stub Joosy.Router, '__respondRoute'
|
51
|
+
|
52
|
+
Joosy.Router.map map
|
53
|
+
Joosy.Router.__setupRoutes()
|
54
|
+
|
55
|
+
expect(Joosy.Router.routes).toEqual Object.extended
|
56
|
+
'^/?/?$':
|
57
|
+
capture: []
|
58
|
+
action: spies.root
|
59
|
+
'^/?page/?$':
|
60
|
+
capture: []
|
61
|
+
action: TestPage
|
62
|
+
'^/?section/page/([^/]+)/?$':
|
63
|
+
capture: ['id']
|
64
|
+
action: spies.section
|
65
|
+
'^/?section/page2/([^/]+)/?$':
|
66
|
+
capture: ['more']
|
67
|
+
action: TestPage
|
68
|
+
|
69
|
+
Joosy.Router.__respondRoute.restore()
|
70
|
+
|
71
|
+
it "should get route params", ->
|
72
|
+
route = Joosy.Router.__prepareRoute "/such/a/long/long/url/:with/:plenty/:of/:params", "123"
|
73
|
+
result = Joosy.Router.__paramsFromRouteMatch ['full regex match here', 1, 2, 3, 4], route.values().first()
|
74
|
+
|
75
|
+
expect(result).toEqual Object.extended
|
76
|
+
'with': 1
|
77
|
+
'plenty': 2
|
78
|
+
'of': 3
|
79
|
+
'params': 4
|
80
|
+
|
81
|
+
it "should build query params", ->
|
82
|
+
result = Joosy.Router.__paramsFromQueryArray ["foo=bar", "bar=baz"]
|
83
|
+
|
84
|
+
expect(result).toEqual Object.extended
|
85
|
+
foo: 'bar'
|
86
|
+
bar: 'baz'
|
87
|
+
|
88
|
+
it "should respond routes", ->
|
89
|
+
sinon.stub Joosy.Router, '__respondRoute'
|
90
|
+
sinon.stub Joosy.Application, 'setCurrentPage'
|
91
|
+
|
92
|
+
Joosy.Router.map map
|
93
|
+
Joosy.Router.__setupRoutes()
|
94
|
+
|
95
|
+
Joosy.Router.__respondRoute.restore()
|
96
|
+
|
97
|
+
Joosy.Router.__respondRoute '/'
|
98
|
+
expect(spies.root.callCount).toEqual 1
|
99
|
+
|
100
|
+
Joosy.Router.__respondRoute '/page'
|
101
|
+
expect(Joosy.Application.setCurrentPage.callCount).toEqual 1
|
102
|
+
expect(Joosy.Application.setCurrentPage.args.last()).toEqual [TestPage, Object.extended()]
|
103
|
+
|
104
|
+
Joosy.Router.__respondRoute '/section/page/1'
|
105
|
+
expect(spies.section.callCount).toEqual 1
|
106
|
+
expect(spies.section.args.last()).toEqual [Object.extended(id: '1')]
|
107
|
+
|
108
|
+
Joosy.Router.__respondRoute '/section/page2/1&a=b'
|
109
|
+
expect(Joosy.Application.setCurrentPage.callCount).toEqual 2
|
110
|
+
expect(Joosy.Application.setCurrentPage.args.last()).toEqual [TestPage, Object.extended(more: '1', a: 'b')]
|
111
|
+
|
112
|
+
Joosy.Router.__respondRoute '/thiswillneverbefound&a=b'
|
113
|
+
expect(spies.wildcard.callCount).toEqual 1
|
114
|
+
expect(spies.wildcard.args.last()).toEqual ['/thiswillneverbefound', Object.extended(a: 'b')]
|
115
|
+
|
116
|
+
Joosy.Application.setCurrentPage.restore()
|
117
|
+
|
118
|
+
it "should navigate", ->
|
119
|
+
Joosy.Router.navigate 'test'
|
120
|
+
expect(location.hash).toEqual '#!test'
|
121
|
+
Joosy.Router.navigate ''
|
122
|
+
expect(location.hash).toEqual '#!'
|
123
|
+
location.hash = ''
|
124
|
+
|
125
|
+
it "should restrict urls", ->
|
126
|
+
sinon.stub Joosy.Router, '__respondRoute'
|
127
|
+
sinon.stub Joosy.Application, 'setCurrentPage'
|
128
|
+
|
129
|
+
Joosy.Router.map map
|
130
|
+
Joosy.Router.__setupRoutes()
|
131
|
+
|
132
|
+
Joosy.Router.__respondRoute.restore()
|
133
|
+
|
134
|
+
Joosy.Router.restrict /^\/page$/
|
135
|
+
|
136
|
+
Joosy.Router.__respondRoute '/page'
|
137
|
+
Joosy.Router.__respondRoute '/section/page/1'
|
138
|
+
|
139
|
+
expect(Joosy.Application.setCurrentPage.callCount).toEqual 1
|
140
|
+
expect(Joosy.Application.setCurrentPage.args.last()).toEqual [TestPage, Object.extended()]
|
141
|
+
|
142
|
+
Joosy.Application.setCurrentPage.restore()
|
143
|
+
Joosy.Router.restrict false
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe "Joosy.Templaters.RailsJST", ->
|
2
|
+
|
3
|
+
beforeEach ->
|
4
|
+
@templater = new Joosy.Templaters.RailsJST()
|
5
|
+
|
6
|
+
class @Klass extends Joosy.Module
|
7
|
+
|
8
|
+
Joosy.namespace 'British.Cities', ->
|
9
|
+
class @Klass extends Joosy.Module
|
10
|
+
|
11
|
+
it "should resolve templates correctly", ->
|
12
|
+
expect(@templater.resolveTemplate(undefined, "/absolute", undefined)).
|
13
|
+
toEqual "absolute"
|
14
|
+
|
15
|
+
expect(@templater.resolveTemplate('widgets', 'fuga', {})).
|
16
|
+
toEqual 'widgets/fuga'
|
17
|
+
|
18
|
+
expect(@templater.resolveTemplate('widgets', 'fuga', new @Klass)).
|
19
|
+
toEqual 'widgets/fuga'
|
20
|
+
|
21
|
+
expect(@templater.resolveTemplate('widgets', 'fuga', new British.Cities.Klass)).
|
22
|
+
toEqual 'widgets/british/cities/fuga'
|
23
|
+
|
24
|
+
expect(@templater.resolveTemplate('widgets', 'hoge/fuga', new British.Cities.Klass)).
|
25
|
+
toEqual 'widgets/british/cities/hoge/fuga'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe "Joosy.Widget", ->
|
2
|
+
|
3
|
+
beforeEach ->
|
4
|
+
class @TestWidget extends Joosy.Widget
|
5
|
+
@box = new @TestWidget()
|
6
|
+
|
7
|
+
it "should have appropriate accessors", ->
|
8
|
+
test = ->
|
9
|
+
@TestWidget.view test
|
10
|
+
expect(@TestWidget::__renderer).toEqual test
|
11
|
+
@TestWidget.view 'test'
|
12
|
+
expect(@TestWidget::__renderer instanceof Function).toBeTruthy()
|
13
|
+
|
14
|
+
it "should use Router", ->
|
15
|
+
target = sinon.stub Joosy.Router, 'navigate'
|
16
|
+
@box.navigate 'there'
|
17
|
+
expect(target.callCount).toEqual 1
|
18
|
+
expect(target.alwaysCalledWithExactly 'there').toBeTruthy()
|
19
|
+
Joosy.Router.navigate.restore()
|
20
|
+
|
21
|
+
it "should load itself", ->
|
22
|
+
@box.data = {tested: true}
|
23
|
+
spies = [sinon.spy()]
|
24
|
+
@TestWidget.view spies[0]
|
25
|
+
@parent = new Joosy.Layout()
|
26
|
+
spies.push sinon.spy(@box, 'refreshElements')
|
27
|
+
spies.push sinon.spy(@box, '__delegateEvents')
|
28
|
+
spies.push sinon.spy(@box, '__runAfterLoads')
|
29
|
+
target = @box.__load @parent, @ground
|
30
|
+
expect(target).toBe @box
|
31
|
+
expect(@box.__renderer.getCall(0).calledOn()).toBeFalsy()
|
32
|
+
expect(@box.__renderer.getCall(0).args[0]).toEqual {tested: true}
|
33
|
+
expect(spies).toBeSequenced()
|
34
|
+
|
35
|
+
it "should unload itself", ->
|
36
|
+
sinon.spy @box, '__runAfterUnloads'
|
37
|
+
@box.__unload()
|
38
|
+
target = @box.__runAfterUnloads
|
39
|
+
expect(target.callCount).toEqual 1
|
40
|
+
expect(target.getCall(0).calledOn()).toBeFalsy()
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe "CachingPreloader", ->
|
2
|
+
|
3
|
+
it "should load JS", ->
|
4
|
+
window.variable_assigned_on_load = undefined
|
5
|
+
localStorage.clear()
|
6
|
+
|
7
|
+
callback = sinon.spy()
|
8
|
+
server = sinon.fakeServer.create()
|
9
|
+
|
10
|
+
load = ->
|
11
|
+
CachingPreloader.load [['/spec/javascripts/support/assets/test.js']],
|
12
|
+
complete: callback
|
13
|
+
|
14
|
+
load()
|
15
|
+
|
16
|
+
expect(server.requests.length).toEqual 1
|
17
|
+
target = server.requests[0]
|
18
|
+
expect(target.method).toEqual 'GET'
|
19
|
+
expect(target.url).toMatch /^\/spec\/javascripts\/support\/assets\/test.js$/
|
20
|
+
target.respond 200, 'Content-Type': 'application/javascript',
|
21
|
+
"window.variable_assigned_on_load = 'yapyap';"
|
22
|
+
|
23
|
+
expect(callback.callCount).toEqual 1
|
24
|
+
expect(window.variable_assigned_on_load).toEqual 'yapyap'
|
25
|
+
window.variable_assigned_on_load = undefined
|
26
|
+
|
27
|
+
load()
|
28
|
+
|
29
|
+
expect(server.requests.length).toEqual 1
|
30
|
+
expect(callback.callCount).toEqual 2
|
31
|
+
expect(window.variable_assigned_on_load).toEqual 'yapyap'
|
32
|
+
|
33
|
+
server.restore()
|
34
|
+
|
35
|
+
window.variable_assigned_on_load = undefined
|
36
|
+
localStorage.clear()
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "InlinePreloader", ->
|
2
|
+
|
3
|
+
it "should load JS", ->
|
4
|
+
window.variable_assigned_on_load = undefined
|
5
|
+
callback = sinon.spy()
|
6
|
+
|
7
|
+
runs ->
|
8
|
+
InlinePreloader.load [['/spec/javascripts/support/assets/test.js']],
|
9
|
+
complete: callback
|
10
|
+
|
11
|
+
waits 100
|
12
|
+
|
13
|
+
runs ->
|
14
|
+
expect(callback.callCount).toEqual 1
|
15
|
+
expect(window.variable_assigned_on_load).toEqual 'yapyap'
|
16
|
+
window.variable_assigned_on_load = undefined
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
window.variable_assigned_on_load = 'yapyap';
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/**
|
2
|
+
* Sinon.JS 1.3.1, 2012/01/04
|
3
|
+
*
|
4
|
+
* @author Christian Johansen (christian@cjohansen.no)
|
5
|
+
*
|
6
|
+
* (The BSD License)
|
7
|
+
*
|
8
|
+
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
|
9
|
+
* All rights reserved.
|
10
|
+
*
|
11
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
12
|
+
* are permitted provided that the following conditions are met:
|
13
|
+
*
|
14
|
+
* * Redistributions of source code must retain the above copyright notice,
|
15
|
+
* this list of conditions and the following disclaimer.
|
16
|
+
* * Redistributions in binary form must reproduce the above copyright notice,
|
17
|
+
* this list of conditions and the following disclaimer in the documentation
|
18
|
+
* and/or other materials provided with the distribution.
|
19
|
+
* * Neither the name of Christian Johansen nor the names of his contributors
|
20
|
+
* may be used to endorse or promote products derived from this software
|
21
|
+
* without specific prior written permission.
|
22
|
+
*
|
23
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
24
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
25
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
27
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
30
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
31
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
32
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
*/
|
34
|
+
|
35
|
+
"use strict";
|
36
|
+
/*global sinon, setTimeout, setInterval, clearTimeout, clearInterval, Date*/
|
37
|
+
/**
|
38
|
+
* Helps IE run the fake timers. By defining global functions, IE allows
|
39
|
+
* them to be overwritten at a later point. If these are not defined like
|
40
|
+
* this, overwriting them will result in anything from an exception to browser
|
41
|
+
* crash.
|
42
|
+
*
|
43
|
+
* If you don't require fake timers to work in IE, don't include this file.
|
44
|
+
*
|
45
|
+
* @author Christian Johansen (christian@cjohansen.no)
|
46
|
+
* @license BSD
|
47
|
+
*
|
48
|
+
* Copyright (c) 2010-2011 Christian Johansen
|
49
|
+
*/
|
50
|
+
function setTimeout() {}
|
51
|
+
function clearTimeout() {}
|
52
|
+
function setInterval() {}
|
53
|
+
function clearInterval() {}
|
54
|
+
function Date() {}
|
55
|
+
|
56
|
+
// Reassign the original functions. Now their writable attribute
|
57
|
+
// should be true. Hackish, I know, but it works.
|
58
|
+
setTimeout = sinon.timers.setTimeout;
|
59
|
+
clearTimeout = sinon.timers.clearTimeout;
|
60
|
+
setInterval = sinon.timers.setInterval;
|
61
|
+
clearInterval = sinon.timers.clearInterval;
|
62
|
+
Date = sinon.timers.Date;
|
63
|
+
|
64
|
+
/*global sinon*/
|
65
|
+
/**
|
66
|
+
* Helps IE run the fake XMLHttpRequest. By defining global functions, IE allows
|
67
|
+
* them to be overwritten at a later point. If these are not defined like
|
68
|
+
* this, overwriting them will result in anything from an exception to browser
|
69
|
+
* crash.
|
70
|
+
*
|
71
|
+
* If you don't require fake XHR to work in IE, don't include this file.
|
72
|
+
*
|
73
|
+
* @author Christian Johansen (christian@cjohansen.no)
|
74
|
+
* @license BSD
|
75
|
+
*
|
76
|
+
* Copyright (c) 2010-2011 Christian Johansen
|
77
|
+
*/
|
78
|
+
function XMLHttpRequest() {}
|
79
|
+
|
80
|
+
// Reassign the original function. Now its writable attribute
|
81
|
+
// should be true. Hackish, I know, but it works.
|
82
|
+
XMLHttpRequest = sinon.xhr.XMLHttpRequest || undefined;
|