|
| 1 | +import Ember from 'ember'; |
1 | 2 | import { moduleForComponent, test } from 'ember-qunit';
|
2 | 3 | import hbs from 'htmlbars-inline-precompile';
|
3 | 4 |
|
| 5 | + |
| 6 | +// Session Stub No Auth |
| 7 | +const sessionStubUnauthenticated = Ember.Service.extend({ |
| 8 | + isAuthenticated: false |
| 9 | +}); |
| 10 | + |
| 11 | +// Session Stub Auth |
| 12 | +const sessionStubAuthenticated = Ember.Service.extend({ |
| 13 | + isAuthenticated: true |
| 14 | +}); |
| 15 | + |
4 | 16 | moduleForComponent('new-navbar-auth-dropdown', 'Integration | Component | new navbar auth dropdown', {
|
5 |
| - integration: true |
| 17 | + integration: true, |
6 | 18 | });
|
7 | 19 |
|
8 |
| -test('it renders', function (assert) { |
9 |
| - // Set any properties with this.set('myProperty', 'value'); |
10 |
| - // Handle any actions with this.on('myAction', function(val) { ... }); |
| 20 | +test('it renders when session is authenticated', function (assert) { |
| 21 | + this.register('service:session', sessionStubAuthenticated); |
| 22 | + this.set('loginAction', ()=>{}); |
| 23 | + this.render(hbs`{{new-navbar-auth-dropdown loginAction=loginAction}}`); |
11 | 24 |
|
12 |
| - this.set('loginAction', ()=>{}); |
13 |
| - this.render(hbs`{{new-navbar-auth-dropdown loginAction=loginAction}}`); |
| 25 | + assert.notOk(this.$('.btn-top-login').length, 'log in button does not exists for authenticated'); |
| 26 | + assert.notOk(this.$('.btn-top-signup').length, 'sign up button does not exists for authenticated'); |
| 27 | + assert.ok(this.$('.osf-profile-image').length, 'has gravatar for authenticated session'); |
| 28 | + assert.ok(this.$('.nav-profile-name').length, 'has username for authenticated session') |
| 29 | + assert.notEqual(this.$().text().trim(), ''); |
| 30 | +}); |
14 | 31 |
|
15 |
| - assert.notEqual(this.$().text().trim(), ''); |
| 32 | +test('it renders when session is not authenticated', function (assert) { |
| 33 | + this.register('service:session', sessionStubUnauthenticated); |
| 34 | + this.set('loginAction', ()=>{}); |
| 35 | + this.render(hbs`{{new-navbar-auth-dropdown loginAction=loginAction}}`); |
| 36 | + assert.ok(this.$('.btn-top-login').length, 'log in button exists for unauthenticated'); |
| 37 | + assert.ok(this.$('.btn-top-signup').length, 'sign up button exists for unauthenticated'); |
| 38 | + assert.notOk(this.$('.osf-profile-image').length, 'no gravatar for unauthenticated session'); |
| 39 | + assert.notOk(this.$('.nav-profile-name').length, 'no username for unauthenticated session') |
| 40 | + assert.notEqual(this.$().text().trim(), ''); |
16 | 41 | });
|
0 commit comments