mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
#48: fix the bug, whent account.current was requested without disabling refreshToken middleware
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import expect from 'unexpected';
|
||||
|
||||
import accounts from 'services/api/accounts';
|
||||
import authentication from 'services/api/authentication';
|
||||
import { authenticate, revoke, add, activate, remove, ADD, REMOVE, ACTIVATE } from 'components/accounts/actions';
|
||||
import { SET_LOCALE } from 'components/i18n/actions';
|
||||
|
||||
@@ -36,11 +37,18 @@ describe('Accounts actions', () => {
|
||||
user: {}
|
||||
});
|
||||
|
||||
sinon.stub(authentication, 'validateToken').named('authentication.validateToken');
|
||||
authentication.validateToken.returns(Promise.resolve({
|
||||
token: account.token,
|
||||
refreshToken: account.refreshToken
|
||||
}));
|
||||
|
||||
sinon.stub(accounts, 'current').named('accounts.current');
|
||||
accounts.current.returns(Promise.resolve(user));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
authentication.validateToken.restore();
|
||||
accounts.current.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -76,10 +76,10 @@ describe('refreshTokenMiddleware', () => {
|
||||
expect(authentication.requestToken, 'was not called');
|
||||
});
|
||||
|
||||
it('should not apply if options.autoRefreshToken === false', () => {
|
||||
it('should not auto refresh token if options.token specified', () => {
|
||||
const data = {
|
||||
url: 'foo',
|
||||
options: {autoRefreshToken: false}
|
||||
options: {token: 'foo'}
|
||||
};
|
||||
middleware.before(data);
|
||||
|
||||
@@ -257,10 +257,10 @@ describe('refreshTokenMiddleware', () => {
|
||||
)
|
||||
);
|
||||
|
||||
it('should pass the request through if options.autoRefreshToken === false', () => {
|
||||
it('should pass the request through if options.token specified', () => {
|
||||
const promise = middleware.catch(expiredResponse, {
|
||||
options: {
|
||||
autoRefreshToken: false
|
||||
token: 'foo'
|
||||
}
|
||||
}, restart);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('authentication api', () => {
|
||||
expect(authentication.validateToken(validTokens), 'to be fulfilled')
|
||||
.then(() => {
|
||||
expect(accounts.current, 'to have a call satisfying', [
|
||||
{token: 'foo', autoRefreshToken: false}
|
||||
{token: 'foo'}
|
||||
]);
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user