spec_app/spec/javascripts/up/link_spec.js.coffee in upjs-rails-0.3.0 vs spec_app/spec/javascripts/up/link_spec.js.coffee in upjs-rails-0.3.2
- old
+ new
@@ -2,34 +2,45 @@
describe 'Javascript functions', ->
describe 'up.follow', ->
- it 'loads the given link via AJAX and replaces the response in the given target', (done) ->
- jasmine.Ajax.install()
-
- affix('.before').text('old-before')
- affix('.middle').text('old-middle')
- affix('.after').text('old-after')
- $link = affix('a[href="/path"][up-target=".middle"]')
-
- promise = up.follow($link)
-
- jasmine.Ajax.requests.mostRecent().respondWith
- status: 200
- contentType: 'text/html'
- responseText:
- """
- <div class="before">new-before</div>
- <div class="middle">new-middle</div>
- <div class="after">new-after</div>
- """
+ if up.browser.canPushState()
+
+ it 'loads the given link via AJAX and replaces the response in the given target', (done) ->
+ jasmine.Ajax.install()
+
+ affix('.before').text('old-before')
+ affix('.middle').text('old-middle')
+ affix('.after').text('old-after')
+ $link = affix('a[href="/path"][up-target=".middle"]')
+
+ promise = up.follow($link)
+
+ jasmine.Ajax.requests.mostRecent().respondWith
+ status: 200
+ contentType: 'text/html'
+ responseText:
+ """
+ <div class="before">new-before</div>
+ <div class="middle">new-middle</div>
+ <div class="after">new-after</div>
+ """
+
+ promise.then ->
+ expect($('.before')).toHaveText('old-before')
+ expect($('.middle')).toHaveText('new-middle')
+ expect($('.after')).toHaveText('old-after')
+ done()
+
+ else
- promise.then ->
- expect($('.before')).toHaveText('old-before')
- expect($('.middle')).toHaveText('new-middle')
- expect($('.after')).toHaveText('old-after')
- done()
+ it 'follows the given link', ->
+ $link = affix('a[href="/path"][up-target=".middle"]')
+ spyOn(up.browser, 'loadPage')
+ up.follow($link)
+ expect(up.browser.loadPage).toHaveBeenCalledWith('/path', jasmine.anything())
+
describe 'up.visit', ->
it 'should have tests'
\ No newline at end of file