Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 413 lines (332 sloc) 14.387 kb
0fac849 @tricknotes Remove unused variable
tricknotes authored
1 { assert, brains, Browser } = require("./helpers")
f6c04bb @assaf Switching from Vows to Mocha.
authored
2 JSDOM = require("jsdom")
53302cc @assaf Redirection is now handled by Zombie instead of Request, set cookies to ...
authored
3 URL = require("url")
f6c04bb @assaf Switching from Vows to Mocha.
authored
4
5
6 describe "History", ->
7
99e9023 @assaf Do not down-case file: URLs.
authored
8 file_url = "file://#{__dirname}/data/index.html"
f6c04bb @assaf Switching from Vows to Mocha.
authored
9
10
11 before (done)->
53302cc @assaf Redirection is now handled by Zombie instead of Request, set cookies to ...
authored
12 brains.get "/history/boo/", (req, res)->
f6c04bb @assaf Switching from Vows to Mocha.
authored
13 response = if req.query.redirected then "Redirected" else "Eeek!"
14 res.send "<html><title>#{response}</title></html>"
15
53302cc @assaf Redirection is now handled by Zombie instead of Request, set cookies to ...
authored
16 brains.get "/history/boo", (req, res)->
17 res.redirect URL.format(pathname: "/history/boo/", query: req.query)
18
f6c04bb @assaf Switching from Vows to Mocha.
authored
19 brains.get "/history/redirect", (req, res)->
20 res.redirect "/history/boo?redirected=true"
21
22 brains.get "/history/redirect_back", (req, res)->
23 res.redirect req.headers["referer"]
24
25 brains.get "/history/referer", (req, res)->
26 res.send "<html><title>#{req.headers["referer"]}</title></html>"
27
be97a26 @assaf Should default referer to browser.referer
authored
28 brains.get "/history/referer2", (req, res)->
29 res.send "<html><title>#{req.headers["referer"]}</title></html>"
30
f6c04bb @assaf Switching from Vows to Mocha.
authored
31 brains.ready done
32
33
34 describe "URL without path", ->
35 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
36 @browser = new Browser()
37 @browser.visit "http://localhost:3003", done
f6c04bb @assaf Switching from Vows to Mocha.
authored
38
39 it "should resolve URL", ->
e6d5bc1 @assaf More tests using promises.
authored
40 assert.equal @browser.location.href, "http://localhost:3003/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
41 it "should load page", ->
e6d5bc1 @assaf More tests using promises.
authored
42 assert.equal @browser.text("title"), "Tap, Tap"
f6c04bb @assaf Switching from Vows to Mocha.
authored
43
44
45 describe "new window", ->
e6d5bc1 @assaf More tests using promises.
authored
46 before ->
40eb7cc @assaf IFrames should work.
authored
47 browser = new Browser()
48 @window = browser.open()
f6c04bb @assaf Switching from Vows to Mocha.
authored
49
aec2e69 @assaf Navigating history should update tab/iframe.
authored
50 it "should start out with one location", ->
51 assert.equal @window.history.length, 1
e6d5bc1 @assaf More tests using promises.
authored
52 assert.equal @window.location.href, "about:blank"
f6c04bb @assaf Switching from Vows to Mocha.
authored
53
54 describe "go forward", ->
55 before ->
e6d5bc1 @assaf More tests using promises.
authored
56 @window.history.forward()
f6c04bb @assaf Switching from Vows to Mocha.
authored
57
58 it "should have no effect", ->
aec2e69 @assaf Navigating history should update tab/iframe.
authored
59 assert.equal @window.history.length, 1
e6d5bc1 @assaf More tests using promises.
authored
60 assert.equal @window.location.href, "about:blank"
f6c04bb @assaf Switching from Vows to Mocha.
authored
61
62 describe "go backwards", ->
63 before ->
e6d5bc1 @assaf More tests using promises.
authored
64 @window.history.back()
f6c04bb @assaf Switching from Vows to Mocha.
authored
65
66 it "should have no effect", ->
aec2e69 @assaf Navigating history should update tab/iframe.
authored
67 assert.equal @window.history.length, 1
e6d5bc1 @assaf More tests using promises.
authored
68 assert.equal @window.location.href, "about:blank"
f6c04bb @assaf Switching from Vows to Mocha.
authored
69
70
71 describe "history", ->
72
73 describe "pushState", ->
74 before (done)->
e9b91fa @assaf Should dispatch events asynchronoulsy when possible
authored
75 @browser = new Browser()
76 @browser.visit "http://localhost:3003/", =>
77 @browser.history.pushState({ is: "start" }, null, "/start")
78 @browser.history.pushState({ is: "end" }, null, "/end")
79 @window = @browser.window
80 @browser.wait(done)
f6c04bb @assaf Switching from Vows to Mocha.
authored
81
0757b43 @assaf Found some misplaced tests
authored
82 it "should add state to history", ->
e6d5bc1 @assaf More tests using promises.
authored
83 assert.equal @window.history.length, 3
0757b43 @assaf Found some misplaced tests
authored
84 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
85 assert.equal @window.location.href, "http://localhost:3003/end"
0757b43 @assaf Found some misplaced tests
authored
86
87 describe "go backwards", ->
88 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
89 @window.document.magic = 123
90 @window.addEventListener "popstate", (@event)=>
0757b43 @assaf Found some misplaced tests
authored
91 done()
e6d5bc1 @assaf More tests using promises.
authored
92 @window.history.back()
e9b91fa @assaf Should dispatch events asynchronoulsy when possible
authored
93 @browser.wait()
0757b43 @assaf Found some misplaced tests
authored
94
95 it "should fire popstate event", ->
e6d5bc1 @assaf More tests using promises.
authored
96 assert @event instanceof JSDOM.dom.level3.events.Event
0757b43 @assaf Found some misplaced tests
authored
97 it "should include state", ->
e6d5bc1 @assaf More tests using promises.
authored
98 assert.equal @event.state.is, "start"
0757b43 @assaf Found some misplaced tests
authored
99 it "should not reload page from same host", ->
100 # Get access to the *current* document
e6d5bc1 @assaf More tests using promises.
authored
101 document = @event.target.window.browser.document
0757b43 @assaf Found some misplaced tests
authored
102 assert.equal document.magic, 123
103
104 describe "go forwards", ->
105 before (done)->
106 browser = new Browser()
e6d5bc1 @assaf More tests using promises.
authored
107 browser.visit "http://localhost:3003/", =>
0757b43 @assaf Found some misplaced tests
authored
108 browser.history.pushState { is: "start" }, null, "/start"
109 browser.history.pushState { is: "end" }, null, "/end"
110 browser.back()
e6d5bc1 @assaf More tests using promises.
authored
111 browser.window.addEventListener "popstate", (@event)=>
f6c04bb @assaf Switching from Vows to Mocha.
authored
112 done()
0757b43 @assaf Found some misplaced tests
authored
113 browser.history.forward()
114
115 it "should fire popstate event", ->
e6d5bc1 @assaf More tests using promises.
authored
116 assert @event instanceof JSDOM.dom.level3.events.Event
0757b43 @assaf Found some misplaced tests
authored
117 it "should include state", ->
e6d5bc1 @assaf More tests using promises.
authored
118 assert.equal @event.state.is, "end"
f6c04bb @assaf Switching from Vows to Mocha.
authored
119
120
121 describe "replaceState", ->
122 before (done)->
e9b91fa @assaf Should dispatch events asynchronoulsy when possible
authored
123 @browser = new Browser()
124 @browser.visit "http://localhost:3003/", =>
125 @browser.history.pushState { is: "start" }, null, "/start"
126 @browser.history.replaceState { is: "end" }, null, "/end"
127 @window = @browser.window
128 @browser.wait(done)
f6c04bb @assaf Switching from Vows to Mocha.
authored
129
130 it "should not add state to history", ->
e6d5bc1 @assaf More tests using promises.
authored
131 assert.equal @window.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
132 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
133 assert.equal @window.location.href, "http://localhost:3003/end"
f6c04bb @assaf Switching from Vows to Mocha.
authored
134
135 describe "go backwards", ->
136 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
137 @window.addEventListener "popstate", (evt)=>
138 @window.popstate = true
139 @window.history.back()
e9b91fa @assaf Should dispatch events asynchronoulsy when possible
authored
140 @browser.wait(done)
f6c04bb @assaf Switching from Vows to Mocha.
authored
141
142 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
143 assert.equal @window.location.href, "http://localhost:3003/"
fa8a37f @assaf Browser should send referer header.
authored
144 it "should fire popstate event", ->
145 assert @window.popstate
f6c04bb @assaf Switching from Vows to Mocha.
authored
146
147
148 describe "redirect", ->
149 browser = new Browser()
150
151 before (done)->
152 browser.visit "http://localhost:3003/history/redirect", done
153
154 it "should redirect to final destination", ->
53302cc @assaf Redirection is now handled by Zombie instead of Request, set cookies to ...
authored
155 assert.equal browser.location, "http://localhost:3003/history/boo/?redirected=true"
f6c04bb @assaf Switching from Vows to Mocha.
authored
156 it "should pass query parameter", ->
157 assert.equal browser.text("title"), "Redirected"
158 it "should not add location in history", ->
159 assert.equal browser.history.length, 1
160 it "should indicate last request followed a redirect", ->
161 assert browser.redirected
162
163 describe "redirect back", ->
164 browser = new Browser()
165
166 before (done)->
167 browser.visit "http://localhost:3003/history/boo", ->
cf7043f @assaf Some hacking required to work with HTML5 parser:
authored
168 browser.visit "http://localhost:3003/history/redirect_back", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
169 done()
170
171 it "should redirect to the previous path", ->
53302cc @assaf Redirection is now handled by Zombie instead of Request, set cookies to ...
authored
172 assert.equal browser.location.href, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
173 it "should pass query parameter", ->
174 assert /Eeek!/.test(browser.text("title"))
175 it "should not add location in history", ->
176 assert.equal browser.history.length, 2
177 it "should indicate last request followed a redirect", ->
178 assert browser.redirected
179
180
181 describe "location", ->
182
183 describe "open page", ->
184 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
185 @browser = new Browser()
186 @browser.visit "http://localhost:3003/", done
f6c04bb @assaf Switching from Vows to Mocha.
authored
187
188 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
189 assert.equal @browser.history.length, 1
f6c04bb @assaf Switching from Vows to Mocha.
authored
190 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
191 assert.equal @browser.location, "http://localhost:3003/"
0757b43 @assaf Found some misplaced tests
authored
192 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
193 assert /Tap, Tap/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
194 it "should set window location", ->
e6d5bc1 @assaf More tests using promises.
authored
195 assert.equal @browser.window.location.href, "http://localhost:3003/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
196 it "should set document location", ->
e6d5bc1 @assaf More tests using promises.
authored
197 assert.equal @browser.document.location.href, "http://localhost:3003/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
198
199 describe "open from file system", ->
200 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
201 @browser = new Browser()
202 @browser.visit file_url, done
f6c04bb @assaf Switching from Vows to Mocha.
authored
203
204 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
205 assert.equal @browser.history.length, 1
f6c04bb @assaf Switching from Vows to Mocha.
authored
206 it "should change location URL", ->
99e9023 @assaf Do not down-case file: URLs.
authored
207 assert.equal @browser.location.href, file_url
f6c04bb @assaf Switching from Vows to Mocha.
authored
208 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
209 assert ~@browser.html("title").indexOf("Insanely fast, headless full-stack testing using Node.js")
f6c04bb @assaf Switching from Vows to Mocha.
authored
210 it "should set window location", ->
e6d5bc1 @assaf More tests using promises.
authored
211 assert.equal @browser.window.location.href, file_url
f6c04bb @assaf Switching from Vows to Mocha.
authored
212 it "should set document location", ->
e6d5bc1 @assaf More tests using promises.
authored
213 assert.equal @browser.document.location.href, file_url
f6c04bb @assaf Switching from Vows to Mocha.
authored
214
27e64d0 @assaf These fixes allow document.write and appendChild to work.
authored
215 describe "change pathname", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
216 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
217 @browser = new Browser()
218 @browser.visit "http://localhost:3003/", =>
219 @browser.window.location.pathname = "/history/boo"
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
220 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
221 done()
97f2621 @assaf History should work as expected
authored
222 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
223
224 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
225 assert.equal @browser.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
226 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
227 assert.equal @browser.location, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
228 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
229 assert /Eeek!/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
230
27e64d0 @assaf These fixes allow document.write and appendChild to work.
authored
231 describe "change relative href", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
232 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
233 @browser = new Browser()
234 @browser.visit "http://localhost:3003/", =>
235 @browser.window.location.href = "/history/boo"
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
236 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
237 done()
97f2621 @assaf History should work as expected
authored
238 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
239
240 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
241 assert.equal @browser.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
242 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
243 assert.equal @browser.location, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
244 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
245 assert /Eeek!/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
246
247 describe "change hash", ->
248 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
249 @browser = new Browser()
250 @browser.visit "http://localhost:3003/", =>
251 @browser.document.innerHTML = "Wolf"
252 @browser.window.addEventListener "hashchange", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
253 done()
e6d5bc1 @assaf More tests using promises.
authored
254 @browser.window.location.hash = "boo"
97f2621 @assaf History should work as expected
authored
255 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
256
257 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
258 assert.equal @browser.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
259 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
260 assert.equal @browser.location, "http://localhost:3003/#boo"
f6c04bb @assaf Switching from Vows to Mocha.
authored
261 it "should not reload document", ->
e6d5bc1 @assaf More tests using promises.
authored
262 assert /Wolf/.test(@browser.document.innerHTML)
f6c04bb @assaf Switching from Vows to Mocha.
authored
263
27e64d0 @assaf These fixes allow document.write and appendChild to work.
authored
264 describe "assign", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
265 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
266 @browser = new Browser()
267 @browser.visit "http://localhost:3003/", =>
268 @browser.window.location.assign "http://localhost:3003/history/boo"
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
269 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
270 done()
97f2621 @assaf History should work as expected
authored
271 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
272
273 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
274 assert.equal @browser.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
275 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
276 assert.equal @browser.location, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
277 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
278 assert /Eeek!/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
279
27e64d0 @assaf These fixes allow document.write and appendChild to work.
authored
280 describe "replace", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
281 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
282 @browser = new Browser()
283 @browser.visit "http://localhost:3003/", =>
284 @browser.window.location.replace "http://localhost:3003/history/boo"
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
285 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
286 done()
97f2621 @assaf History should work as expected
authored
287 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
288
289 it "should not add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
290 assert.equal @browser.history.length, 1
f6c04bb @assaf Switching from Vows to Mocha.
authored
291 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
292 assert.equal @browser.location, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
293 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
294 assert /Eeek!/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
295
97f2621 @assaf History should work as expected
authored
296 describe "reload", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
297 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
298 @browser = new Browser()
299 @browser.visit "http://localhost:3003/", =>
300 @browser.window.document.innerHTML = "Wolf"
301 @browser.reload()
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
302 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
303 done()
97f2621 @assaf History should work as expected
authored
304 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
305
306 it "should not add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
307 assert.equal @browser.history.length, 1
f6c04bb @assaf Switching from Vows to Mocha.
authored
308 it "should not change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
309 assert.equal @browser.location, "http://localhost:3003/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
310 it "should reload document", ->
e6d5bc1 @assaf More tests using promises.
authored
311 assert /Tap, Tap/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
312
313 describe "components", ->
314 before (done)->
315 browser = new Browser()
e6d5bc1 @assaf More tests using promises.
authored
316 browser.visit "http://localhost:3003/", =>
317 @location = browser.location
f6c04bb @assaf Switching from Vows to Mocha.
authored
318 done()
319
320 it "should include protocol", ->
e6d5bc1 @assaf More tests using promises.
authored
321 assert.equal @location.protocol, "http:"
f6c04bb @assaf Switching from Vows to Mocha.
authored
322 it "should include hostname", ->
e6d5bc1 @assaf More tests using promises.
authored
323 assert.equal @location.hostname, "localhost"
f6c04bb @assaf Switching from Vows to Mocha.
authored
324 it "should include port", ->
e6d5bc1 @assaf More tests using promises.
authored
325 assert.equal @location.port, 3003
f6c04bb @assaf Switching from Vows to Mocha.
authored
326 it "should include hostname and port", ->
e6d5bc1 @assaf More tests using promises.
authored
327 assert.equal @location.host, "localhost:3003"
f6c04bb @assaf Switching from Vows to Mocha.
authored
328 it "should include pathname", ->
e6d5bc1 @assaf More tests using promises.
authored
329 assert.equal @location.pathname, "/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
330 it "should include search", ->
97f2621 @assaf History should work as expected
authored
331 assert.equal @location.search, ""
f6c04bb @assaf Switching from Vows to Mocha.
authored
332 it "should include hash", ->
e6d5bc1 @assaf More tests using promises.
authored
333 assert.equal @location.hash, ""
f6c04bb @assaf Switching from Vows to Mocha.
authored
334
27e64d0 @assaf These fixes allow document.write and appendChild to work.
authored
335 describe "set window.location", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
336 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
337 @browser = new Browser()
338 @browser.visit "http://localhost:3003/", =>
339 @browser.window.location = "http://localhost:3003/history/boo"
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
340 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
341 done()
97f2621 @assaf History should work as expected
authored
342 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
343
344 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
345 assert.equal @browser.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
346 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
347 assert.equal @browser.location, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
348 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
349 assert /Eeek!/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
350
27e64d0 @assaf These fixes allow document.write and appendChild to work.
authored
351 describe "set document.location", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
352 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
353 @browser = new Browser()
354 @browser.visit "http://localhost:3003/", =>
355 @browser.window.document.location = "http://localhost:3003/history/boo"
ee4ab2f @assaf [Closes #345] Create DOM document after Web page has loaded.
authored
356 @browser.on "loaded", ->
f6c04bb @assaf Switching from Vows to Mocha.
authored
357 done()
97f2621 @assaf History should work as expected
authored
358 @browser.wait()
f6c04bb @assaf Switching from Vows to Mocha.
authored
359
360 it "should add page to history", ->
e6d5bc1 @assaf More tests using promises.
authored
361 assert.equal @browser.history.length, 2
f6c04bb @assaf Switching from Vows to Mocha.
authored
362 it "should change location URL", ->
e6d5bc1 @assaf More tests using promises.
authored
363 assert.equal @browser.location, "http://localhost:3003/history/boo/"
f6c04bb @assaf Switching from Vows to Mocha.
authored
364 it "should load document", ->
e6d5bc1 @assaf More tests using promises.
authored
365 assert /Eeek!/.test(@browser.html())
f6c04bb @assaf Switching from Vows to Mocha.
authored
366
367
368 describe "referer not set", ->
369
370 describe "first page", ->
371 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
372 @browser = new Browser()
373 @browser.visit "http://localhost:3003/history/referer", done
f6c04bb @assaf Switching from Vows to Mocha.
authored
374
375 it "should be empty", ->
e6d5bc1 @assaf More tests using promises.
authored
376 assert.equal @browser.text("title"), "undefined"
f6c04bb @assaf Switching from Vows to Mocha.
authored
377
378 describe "second page", ->
379 before (done)->
be97a26 @assaf Should default referer to browser.referer
authored
380 @browser.visit "http://localhost:3003/history/referer2", done
f6c04bb @assaf Switching from Vows to Mocha.
authored
381
382 it "should point to first page", ->
e6d5bc1 @assaf More tests using promises.
authored
383 assert.equal @browser.text("title"), "http://localhost:3003/history/referer"
f6c04bb @assaf Switching from Vows to Mocha.
authored
384
385 describe "referer set", ->
386
387 describe "first page", ->
388 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
389 @browser = new Browser()
390 @browser.visit "http://localhost:3003/history/referer", referer: "http://braindepot", done
f6c04bb @assaf Switching from Vows to Mocha.
authored
391
be97a26 @assaf Should default referer to browser.referer
authored
392 it "should be set from browser", ->
e6d5bc1 @assaf More tests using promises.
authored
393 assert.equal @browser.text("title"), "http://braindepot"
f6c04bb @assaf Switching from Vows to Mocha.
authored
394
395 describe "second page", ->
396 before (done)->
be97a26 @assaf Should default referer to browser.referer
authored
397 @browser.visit "http://localhost:3003/history/referer2", done
f6c04bb @assaf Switching from Vows to Mocha.
authored
398
399 it "should point to first page", ->
e6d5bc1 @assaf More tests using promises.
authored
400 assert.equal @browser.text("title"), "http://localhost:3003/history/referer"
f6c04bb @assaf Switching from Vows to Mocha.
authored
401
208524a @assaf Fix loading URL with document fragment remove document fragment from pag...
authored
402
403 describe "URL with hash", ->
404 before (done)->
e6d5bc1 @assaf More tests using promises.
authored
405 @browser = new Browser()
406 @browser.visit "http://localhost:3003#with-hash", done
208524a @assaf Fix loading URL with document fragment remove document fragment from pag...
authored
407
408 it "should load page", ->
e6d5bc1 @assaf More tests using promises.
authored
409 assert.equal @browser.text("title"), "Tap, Tap"
208524a @assaf Fix loading URL with document fragment remove document fragment from pag...
authored
410 it "should set location to hash", ->
e6d5bc1 @assaf More tests using promises.
authored
411 assert.equal @browser.location.hash, "#with-hash"
208524a @assaf Fix loading URL with document fragment remove document fragment from pag...
authored
412
Something went wrong with that request. Please try again.