fix: refs #7065 made consts for repeated values
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
PAU ROVIRA ROSALENY 2025-01-28 10:07:51 +01:00
parent 8146aa5231
commit c8cd14f991
1 changed files with 10 additions and 14 deletions

View File

@ -10,13 +10,6 @@ describe('UserPanel', () => {
let wrapper;
let vm;
let state;
let axiosPatchMock;
let axiosPostMock;
beforeAll(() => {
axiosPatchMock = vi.spyOn(axios, 'patch').mockResolvedValue({});
axiosPostMock = vi.spyOn(axios, 'post').mockResolvedValue({});
});
beforeEach(() => {
wrapper = createWrapper(UserPanel, {});
@ -46,22 +39,25 @@ describe('UserPanel', () => {
it('should toggle dark mode correctly and update preferences', async () => {
await vm.saveDarkMode(true);
expect(axiosPatchMock).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
expect(vm.user.darkMode).toBe(true);
vm.updatePreferences();
expect(vm.darkMode).toBe(true);
});
it('should change user language and update preferences', async () => {
await vm.saveLanguage('es');
expect(axiosPatchMock).toHaveBeenCalledWith('/VnUsers/115', { lang: 'es' });
expect(vm.user.lang).toBe('es');
const userLanguage = 'es';
await vm.saveLanguage(userLanguage);
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
expect(vm.user.lang).toBe(userLanguage);
vm.updatePreferences();
expect(vm.locale).toBe('es');
expect(vm.locale).toBe(userLanguage);
});
it('should update user data', async () => {
await vm.saveUserData('name', 'itboss');
expect(axiosPostMock).toHaveBeenCalledWith('UserConfigs/setUserConfig', { ['name']: 'itboss' });
const key = 'name';
const value = 'itboss';
await vm.saveUserData(key, value);
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
});
});