test: fix test

This commit is contained in:
Javier Segarra 2025-03-28 12:03:15 +01:00
parent 2a3e072b1b
commit 50fb8a31a6
2 changed files with 8 additions and 6 deletions

View File

@ -23,18 +23,19 @@ describe('useRole', () => {
name: `T'Challa`, name: `T'Challa`,
nickname: 'Black Panther', nickname: 'Black Panther',
lang: 'en', lang: 'en',
worker: { department: { departmentFk: 155 } },
}; };
const expectedUser = { const expectedUser = {
id: 999, id: 999,
name: `T'Challa`, name: `T'Challa`,
nickname: 'Black Panther', nickname: 'Black Panther',
lang: 'en', lang: 'en',
departmentFk: 155,
}; };
const expectedRoles = ['salesPerson', 'admin']; const expectedRoles = ['salesPerson', 'admin'];
vi.spyOn(axios, 'get') vi.spyOn(axios, 'get').mockResolvedValueOnce({
.mockResolvedValueOnce({
data: { roles: rolesData, user: fetchedUser }, data: { roles: rolesData, user: fetchedUser },
}) });
vi.spyOn(role.state, 'setUser'); vi.spyOn(role.state, 'setUser');
vi.spyOn(role.state, 'setRoles'); vi.spyOn(role.state, 'setRoles');

View File

@ -75,6 +75,7 @@ describe('session', () => {
userConfig: { userConfig: {
darkMode: false, darkMode: false,
}, },
worker: { department: { departmentFk: 155 } },
}; };
const rolesData = [ const rolesData = [
{ {
@ -143,7 +144,7 @@ describe('session', () => {
await session.destroy(); // this clears token and user for any other test await session.destroy(); // this clears token and user for any other test
}); });
}, },
{} {},
); );
describe('RenewToken', () => { describe('RenewToken', () => {
@ -175,7 +176,7 @@ describe('session', () => {
await session.checkValidity(); await session.checkValidity();
expect(sessionStorage.getItem('token')).toEqual(expectedToken); expect(sessionStorage.getItem('token')).toEqual(expectedToken);
expect(sessionStorage.getItem('tokenMultimedia')).toEqual( expect(sessionStorage.getItem('tokenMultimedia')).toEqual(
expectedTokenMultimedia expectedTokenMultimedia,
); );
}); });
it('Should renewToken', async () => { it('Should renewToken', async () => {
@ -204,7 +205,7 @@ describe('session', () => {
await session.checkValidity(); await session.checkValidity();
expect(sessionStorage.getItem('token')).not.toEqual(expectedToken); expect(sessionStorage.getItem('token')).not.toEqual(expectedToken);
expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual( expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual(
expectedTokenMultimedia expectedTokenMultimedia,
); );
}); });
}); });