Skip to content

Commit

Permalink
Update mon-pix/tests/unit/routes/login-pe_test.js
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Perret <j-github@jonathanperret.net>
  • Loading branch information
2 people authored and lisequesnel committed Feb 21, 2022
1 parent f63c77e commit c0eb3e6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mon-pix/tests/unit/routes/login-pe_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import sinon from 'sinon';
import { setupTest } from 'ember-mocha';
Expand All @@ -6,18 +7,20 @@ describe('Unit | Route | login-pe', function () {
setupTest();

let route;
const loginTransition = Symbol('login transition');

beforeEach(function () {
route = this.owner.lookup('route:login-pe');
sinon.stub(route, 'replaceWith');
route.replaceWith.withArgs('login').returns(loginTransition);
});

context('when pole-emploi user disallow PIX to use data', function () {
const queryParams = {
error: 'access_denied',
};

it('should redirect to login route if there is an error in transition.to', async function () {
it('should redirect to login route if there is an error in transition.to', function () {
// given
const transition = {
to: {
Expand All @@ -26,23 +29,23 @@ describe('Unit | Route | login-pe', function () {
};

// when
await route.beforeModel(transition);
const transitionResult = route.beforeModel(transition);

// then
sinon.assert.calledWith(route.replaceWith, 'login');
expect(transitionResult).to.equal(loginTransition);
});

it('should redirect to login route if there is an error in transition', async function () {
it('should redirect to login route if there is an error in transition', function () {
// given
const transition = {
queryParams,
};

// when
await route.beforeModel(transition);
const transitionResult = route.beforeModel(transition);

// then
sinon.assert.calledWith(route.replaceWith, 'login');
expect(transitionResult).to.equal(loginTransition);
});
});
});

0 comments on commit c0eb3e6

Please sign in to comment.