fix: refs #7065 made consts for repeated values
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
8146aa5231
commit
c8cd14f991
|
@ -10,13 +10,6 @@ describe('UserPanel', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
let vm;
|
let vm;
|
||||||
let state;
|
let state;
|
||||||
let axiosPatchMock;
|
|
||||||
let axiosPostMock;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
axiosPatchMock = vi.spyOn(axios, 'patch').mockResolvedValue({});
|
|
||||||
axiosPostMock = vi.spyOn(axios, 'post').mockResolvedValue({});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = createWrapper(UserPanel, {});
|
wrapper = createWrapper(UserPanel, {});
|
||||||
|
@ -46,22 +39,25 @@ describe('UserPanel', () => {
|
||||||
|
|
||||||
it('should toggle dark mode correctly and update preferences', async () => {
|
it('should toggle dark mode correctly and update preferences', async () => {
|
||||||
await vm.saveDarkMode(true);
|
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);
|
expect(vm.user.darkMode).toBe(true);
|
||||||
vm.updatePreferences();
|
vm.updatePreferences();
|
||||||
expect(vm.darkMode).toBe(true);
|
expect(vm.darkMode).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change user language and update preferences', async () => {
|
it('should change user language and update preferences', async () => {
|
||||||
await vm.saveLanguage('es');
|
const userLanguage = 'es';
|
||||||
expect(axiosPatchMock).toHaveBeenCalledWith('/VnUsers/115', { lang: 'es' });
|
await vm.saveLanguage(userLanguage);
|
||||||
expect(vm.user.lang).toBe('es');
|
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
||||||
|
expect(vm.user.lang).toBe(userLanguage);
|
||||||
vm.updatePreferences();
|
vm.updatePreferences();
|
||||||
expect(vm.locale).toBe('es');
|
expect(vm.locale).toBe(userLanguage);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update user data', async () => {
|
it('should update user data', async () => {
|
||||||
await vm.saveUserData('name', 'itboss');
|
const key = 'name';
|
||||||
expect(axiosPostMock).toHaveBeenCalledWith('UserConfigs/setUserConfig', { ['name']: 'itboss' });
|
const value = 'itboss';
|
||||||
|
await vm.saveUserData(key, value);
|
||||||
|
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue