diff options
author | Jefferson Stachelski <jeffhsta@riseup.net> | 2015-12-03 20:56:47 -0200 |
---|---|---|
committer | Pixelated <pixelated@pix-poa-1> | 2015-12-03 21:16:58 -0200 |
commit | 6df57ef709f0a19e467a5a88bc854f4e5f8e00f7 (patch) | |
tree | 4bd64040d9d2a159d781d066f397edae74ad04f7 /web-ui | |
parent | 7524cb21facf3d739d29e312ffe85bda7377f261 (diff) |
Issue #411 - Fixed the tests [Gil/Jeff]
Diffstat (limited to 'web-ui')
-rw-r--r-- | web-ui/test/spec/page/user_settings_box.spec.js | 31 | ||||
-rw-r--r-- | web-ui/test/spec/user_settings/data/user_settings.spec.js | 28 | ||||
-rw-r--r-- | web-ui/test/spec/user_settings/ui/user_settings_box.spec.js | 24 | ||||
-rw-r--r-- | web-ui/test/spec/user_settings/ui/user_settings_icon.spec.js (renamed from web-ui/test/spec/page/user_settings_icon.spec.js) | 2 | ||||
-rw-r--r-- | web-ui/test/test-main.js | 3 |
5 files changed, 55 insertions, 33 deletions
diff --git a/web-ui/test/spec/page/user_settings_box.spec.js b/web-ui/test/spec/page/user_settings_box.spec.js deleted file mode 100644 index f769d313..00000000 --- a/web-ui/test/spec/page/user_settings_box.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -describeComponent('page/user_settings_box', function () { - 'use strict'; - - var features; - - beforeEach(function () { - this.setupComponent(); - features = require('features'); - }); - - it('is extra high when the logout button is present', function() { - spyOn(features, 'isLogoutEnabled').and.returnValue(true); - - expect(this.$node.hasClass('extra-bottom-space')).toBe(true); - }); - - it('toggles when receiving a toggle event', function () { - expect(this.$node.hasClass('hidden')).toBe(false); - this.component.trigger(document, Pixelated.events.ui.userSettingsBox.toggle); - expect(this.$node.hasClass('hidden')).toBe(true); - this.component.trigger(document, Pixelated.events.ui.userSettingsBox.toggle); - expect(this.$node.hasClass('hidden')).toBe(false); - }); - - it('hides iteslf when the right arrow is clicked', function () { - this.$node.removeClass('hidden'); - this.component.select('close').click(); - - expect(this.$node.hasClass('hidden')).toBe(true); - }); -}); diff --git a/web-ui/test/spec/user_settings/data/user_settings.spec.js b/web-ui/test/spec/user_settings/data/user_settings.spec.js new file mode 100644 index 00000000..0fff7fae --- /dev/null +++ b/web-ui/test/spec/user_settings/data/user_settings.spec.js @@ -0,0 +1,28 @@ +describeComponent('user_settings/data/user_settings', function () { + 'use strict'; + + beforeEach(function () { + this.setupComponent(); + }); + + it('gets user info from the server', function() { + var data = {account_email: 'user@pixelated.org'}; + var deferred = $.Deferred(); + + spyOn($, 'ajax').and.returnValue(deferred); + this.component.getUserSettings(); + deferred.resolve(); + + expect($.ajax.calls.mostRecent().args[0]).toEqual('/user-settings'); + expect($.ajax.calls.mostRecent().args[1].type).toEqual('GET'); + }); + + it('send user info when event userSettings.getInfo is trigged', function() { + var data = {account_email: 'user@pixelated.org'}; + var eventSpy = spyOnEvent(document, Pixelated.events.userSettings.here); + + this.component.trigger(document, Pixelated.events.userSettings.getInfo); + + expect(eventSpy).toHaveBeenTriggeredOn(document); + }); +}); diff --git a/web-ui/test/spec/user_settings/ui/user_settings_box.spec.js b/web-ui/test/spec/user_settings/ui/user_settings_box.spec.js new file mode 100644 index 00000000..d5919ca7 --- /dev/null +++ b/web-ui/test/spec/user_settings/ui/user_settings_box.spec.js @@ -0,0 +1,24 @@ +describeComponent('user_settings/ui/user_settings_box', function () { + 'use strict'; + + beforeEach(function () { + Pixelated.mockBloodhound(); + this.setupComponent(); + this.component.render(null, {}); + }); + + it('is extra high when the logout button is present', function() { + var features = require('features'); + spyOn(features, 'isLogoutEnabled').and.returnValue(true); + + expect(this.$node.hasClass('extra-bottom-space')).toBe(true); + }); + + it('destroy it self when the close button is clicked', function () { + var destroyEvent = spyOnEvent(document, Pixelated.events.userSettings.destroyPopup); + + this.$node.find('.fa-close').click(); + + expect(destroyEvent).toHaveBeenTriggeredOn(document); + }); +}); diff --git a/web-ui/test/spec/page/user_settings_icon.spec.js b/web-ui/test/spec/user_settings/ui/user_settings_icon.spec.js index 60e06d36..b06cf033 100644 --- a/web-ui/test/spec/page/user_settings_icon.spec.js +++ b/web-ui/test/spec/user_settings/ui/user_settings_icon.spec.js @@ -1,4 +1,4 @@ -describeComponent('page/user_settings_icon', function () { +describeComponent('user_settings/ui/user_settings_icon', function () { 'use strict'; beforeEach(function () { diff --git a/web-ui/test/test-main.js b/web-ui/test/test-main.js index 42ff1ba2..cfd2d81c 100644 --- a/web-ui/test/test-main.js +++ b/web-ui/test/test-main.js @@ -31,7 +31,8 @@ requirejs.config({ 'quoted-printable': 'app/bower_components/quoted-printable', 'utf8': 'app/bower_components/utf8', 'test': 'test', - 'features': 'test/features' + 'features': 'test/features', + 'user_settings': 'app/js/user_settings' }, |