diff options
author | Ola Bini <ola.bini@gmail.com> | 2014-07-31 19:29:33 -0300 |
---|---|---|
committer | Ola Bini <ola.bini@gmail.com> | 2014-07-31 19:29:33 -0300 |
commit | 04cf441c5ae18400c6b4865b0b37a71718dc9d46 (patch) | |
tree | dd0b0d049ec00389e2d4561b226c46eb1682b997 /web-ui/test/spec/page/router | |
parent | 639a663a4c37020003586438fdcd7ac529a00f10 (diff) |
Add web-ui based on previous code
Diffstat (limited to 'web-ui/test/spec/page/router')
-rw-r--r-- | web-ui/test/spec/page/router/url_params.spec.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/web-ui/test/spec/page/router/url_params.spec.js b/web-ui/test/spec/page/router/url_params.spec.js new file mode 100644 index 00000000..a14ba1ba --- /dev/null +++ b/web-ui/test/spec/page/router/url_params.spec.js @@ -0,0 +1,68 @@ +require(['page/router/url_params'], function (urlParams) { + + describe('urlParams', function () { + + beforeEach(function () { + //preventing the hash change to fire the onpopstate event in other components + //in this case in the router component + window.onpopstate = function () {}; + }); + + afterEach(function () { + document.location.hash = ''; + }); + + describe('getTag', function () { + it('returns inbox if there is no tag in the url hash', function () { + expect(urlParams.getTag()).toEqual('inbox'); + }); + + it('returns the tag in the hash if there is one', function () { + document.location.hash = '/Drafts'; + + expect(urlParams.getTag()).toEqual('Drafts'); + }); + + it('returns tag with slash', function () { + document.location.hash = '/Events/2011'; + + expect(urlParams.getTag()).toEqual('Events/2011'); + }); + + it('returns tag even if there is an mail ident', function () { + document.location.hash = '/Events/2011/mail/1'; + + expect(urlParams.getTag()).toEqual('Events/2011'); + }); + + it('returns the tag even if there is a trailing slash', function () { + document.location.hash = '/Events/'; + + expect(urlParams.getTag()).toEqual('Events'); + }); + }); + + describe('hasMailIdent', function () { + it('is true if hash has mailIdent', function () { + document.location.hash = '/inbox/mail/1'; + + expect(urlParams.hasMailIdent()).toBeTruthy(); + }); + + it('is false if hash has no mail ident', function () { + document.location.hash = '/Drafts'; + + expect(urlParams.hasMailIdent()).toBeFalsy(); + }); + }); + + describe('getMailIdent', function () { + it('returns the mail ident that is in the hash', function () { + document.location.hash = '/inbox/mail/123'; + + expect(urlParams.getMailIdent()).toEqual('123'); + }); + }); + }); + +}); |