Skip to content

Commit

Permalink
don't restore spies individually
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow committed Mar 22, 2019
1 parent 6a9a0fa commit 30b1041
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 1 addition & 7 deletions tests/unit/internal-session-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,21 +387,15 @@ describe('InternalSession', () => {
});

describe('when invalidate gets called with additional params', function() {
let spy;

beforeEach(function() {
spy = sinon.spy(authenticator, 'invalidate');
sinon.spy(authenticator, 'invalidate');
});

it('passes the params on to the authenticators invalidate method', function() {
let param = { some: 'random data' };
session.invalidate(param);
expect(authenticator.invalidate).to.have.been.calledWith(session.get('authenticated'), param);
});

afterEach(function() {
spy.restore();
});
});

describe('when the authenticator resolves invalidation', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ describe('OAuth2ImplicitGrantCallbackRouteMixin', function() {
});

describe('#activate', function() {
let sinon;
beforeEach(function() {
sinon = sinonjs.sandbox.create();
session = EmberObject.extend({
authenticate(authenticator, hash) {
if (!isEmpty(hash.access_token)) {
Expand All @@ -45,9 +43,6 @@ describe('OAuth2ImplicitGrantCallbackRouteMixin', function() {

sinon.spy(route, 'transitionTo');
});
afterEach(function() {
sinon.restore();
});

it('correctly passes the auth parameters if authentication succeeds', function(done) {
// it isn't possible to stub window.location.hash so we stub a wrapper function instead
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/mixins/unauthenticated-route-mixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@ import RSVP from 'rsvp';
import Route from '@ember/routing/route';
import { describe, beforeEach, it } from 'mocha';
import { expect } from 'chai';
import sinon from 'sinon';
import sinonjs from 'sinon';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
import InternalSession from 'ember-simple-auth/internal-session';
import EphemeralStore from 'ember-simple-auth/session-stores/ephemeral';
import createWithContainer from '../../helpers/create-with-container';

describe('UnauthenticatedRouteMixin', () => {
let sinon;
let route;
let session;
let containerMock;

beforeEach(function() {
sinon = sinonjs.sandbox.create();
});

afterEach(function() {
sinon.restore();
});

describe('#beforeModel', function() {
beforeEach(function() {
const MixinImplementingBeforeModel = Mixin.create({
Expand Down

0 comments on commit 30b1041

Please sign in to comment.