describe 'up.navigation', -> describe 'unobtrusive behavior', -> it 'marks a link as .up-current if it links to the current URL', -> spyOn(up.browser, 'url').and.returnValue('/foo') $currentLink = up.ready(affix('a[href="/foo"]')) $otherLink = up.ready(affix('a[href="/bar"]')) expect($currentLink).toHaveClass('up-current') expect($otherLink).not.toHaveClass('up-current') it 'marks any link as .up-current if its up-href attribute matches the current URL', -> spyOn(up.browser, 'url').and.returnValue('/foo') $currentLink = up.ready(affix('span[up-href="/foo"]')) $otherLink = up.ready(affix('span[up-href="/bar"]')) expect($currentLink).toHaveClass('up-current') expect($otherLink).not.toHaveClass('up-current') it 'marks any link as .up-current if any of its space-separated up-alias values matches the current URL', -> spyOn(up.browser, 'url').and.returnValue('/foo') $currentLink = up.ready(affix('span[up-alias="/aaa /foo /bbb"]')) $otherLink = up.ready(affix('span[up-alias="/bar"]')) expect($currentLink).toHaveClass('up-current') expect($otherLink).not.toHaveClass('up-current') it 'does not throw if the current location does not match an up-alias wildcard (bugfix)', -> inserter = -> up.ready(affix('a[up-alias="/qqqq*"]')) expect(inserter).not.toThrow() it 'marks URL prefixes as .up-current if an up-alias value ends in *', -> spyOn(up.browser, 'url').and.returnValue('/foo/123') $currentLink = up.ready(affix('span[up-alias="/aaa /foo/* /bbb"]')) $otherLink = up.ready(affix('span[up-alias="/bar"]')) expect($currentLink).toHaveClass('up-current') expect($otherLink).not.toHaveClass('up-current') if up.browser.canPushState() it 'marks a link as .up-current if it links to the current URL, but is missing a trailing slash', -> $link = affix('a[href="/foo"][up-target=".main"]') affix('.main') $link.click() jasmine.Ajax.requests.mostRecent().respondWith status: 200 contentType: 'text/html' responseHeaders: { 'X-Up-Location': '/foo/' } responseText: '