hhff/spree-ember

View on GitHub
packages/auth/tests/acceptance/signin-test.js

Summary

Maintainability
A
3 hrs
Test Coverage
import Ember from 'ember';
import {
  module,
  test
} from 'qunit';
import startApp from '../helpers/start-app';

var application;

module('Acceptance: Signin', {
  beforeEach: function() {
    window.localStorage.clear();
    application = startApp();
  },

  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

test('cant get to account unless authenticated', function(assert) {
  visit('/account');

  andThen(function() {
    assert.equal(currentPath(), 'spree.signin');
    fillIn('input[placeholder="Email"]', 'spree-ember@example.com');
    fillIn('input[placeholder="Password"]', 'spree123');
    click('button[type="submit"]');
  });

  andThen(function() {
    assert.equal(currentPath(), 'spree.account');
  });
});


test('once authenticated, cant get to auth routes', function(assert) {
  visit('/signin');

  andThen(function() {
    assert.equal(currentPath(), 'spree.signin');
    fillIn('input[placeholder="Email"]', 'spree-ember@example.com');
    fillIn('input[placeholder="Password"]', 'spree123');
    click('button[type="submit"]');
  });

  andThen(function() {
    assert.equal(currentPath(), 'spree.account');
  });

  andThen(function() {
    visit('/signin');
  });

  andThen(function() {
    assert.equal(currentPath(), 'spree.account');
  });
  
  andThen(function() {
    visit('/signup');
  });

  andThen(function() {
    assert.equal(currentPath(), 'spree.account');
  });
});