Skip to content

Commit 4478fb8

Browse files
committed
Use navigate helper for fragment tests
1 parent dc4712a commit 4478fb8

File tree

1 file changed

+15
-58
lines changed

1 file changed

+15
-58
lines changed

test/unit/pjax.js

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -272,78 +272,35 @@ if ($.support.pjax) {
272272
})
273273
})
274274

275-
asyncTest("only fragment is inserted", function() {
276-
var frame = this.frame
277-
278-
frame.$('#main').on('pjax:success', function(event, data) {
279-
equal(typeof data, 'string')
275+
asyncTest("only fragment is inserted", 2, function() {
276+
navigate(this.frame)
277+
.pjax({ url: "hello.html?layout=true", fragment: "#main", container: "#main" }, function(frame) {
280278
equal(frame.$("#main > p").html().trim(), "Hello!")
281-
start()
282-
})
283-
frame.$.pjax({
284-
url: "hello.html?layout=true",
285-
fragment: "#main",
286-
container: "#main"
287-
})
288-
})
289-
290-
asyncTest("use body as fragment", function() {
291-
var frame = this.frame
292-
293-
frame.$('body').on('pjax:success', function(event, data) {
294-
equal(typeof data, 'string')
295-
equal(frame.$("body > #main > p").html().trim(), "Hello!")
296279
equal(frame.document.title, "Hello")
297-
start()
298-
})
299-
frame.$.pjax({
300-
url: "hello.html?layout=true",
301-
fragment: "body",
302-
container: "body"
303280
})
304281
})
305282

306-
asyncTest("fragment sets title to response title tag", function() {
307-
var frame = this.frame
308-
309-
frame.$('#main').on('pjax:success', function() {
283+
asyncTest("use body as fragment", 2, function() {
284+
navigate(this.frame)
285+
.pjax({ url: "hello.html?layout=true", fragment: "body", container: "body" }, function(frame) {
286+
equal(frame.$("body > #main > p").html().trim(), "Hello!")
310287
equal(frame.document.title, "Hello")
311-
start()
312-
})
313-
frame.$.pjax({
314-
url: "hello.html?layout=true",
315-
fragment: "#main",
316-
container: "#main"
317288
})
318289
})
319290

320-
asyncTest("fragment sets title to response title attr", function() {
321-
var frame = this.frame
322-
323-
frame.$('#main').on('pjax:success', function() {
291+
asyncTest("fragment sets title to response title attr", 2, function() {
292+
navigate(this.frame)
293+
.pjax({ url: "fragment.html", fragment: "#foo", container: "#main" }, function(frame) {
294+
equal(frame.$("#main > p").html(), "Foo")
324295
equal(frame.document.title, "Foo")
325-
equal(frame.$("#main p").html(), "Foo")
326-
start()
327-
})
328-
frame.$.pjax({
329-
url: "fragment.html",
330-
fragment: "#foo",
331-
container: "#main"
332296
})
333297
})
334298

335-
asyncTest("fragment sets title to response data-title attr", function() {
336-
var frame = this.frame
337-
338-
frame.$('#main').on('pjax:success', function() {
299+
asyncTest("fragment sets title to response data-title attr", 2, function() {
300+
navigate(this.frame)
301+
.pjax({ url: "fragment.html", fragment: "#bar", container: "#main" }, function(frame) {
302+
equal(frame.$("#main > p").html(), "Bar")
339303
equal(frame.document.title, "Bar")
340-
equal(frame.$("#main p").html(), "Bar")
341-
start()
342-
})
343-
frame.$.pjax({
344-
url: "fragment.html",
345-
fragment: "#bar",
346-
container: "#main"
347304
})
348305
})
349306

0 commit comments

Comments
 (0)