completion

This commit is contained in:
2025-08-06 13:49:11 +08:00
commit c2d7317897
684 changed files with 92987 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/* global describe: true, test:true, expect:true */
import { settings as settingsReducer, initialState } from '~/reducers/settings';
import {
GET_SETTINGS_SUCCESS,
SET_SETTINGS_SUCCESS,
LOGOUT_SUCCESS,
} from '~/store/actionTypes';
describe('settings reducer', () => {
test('CASE 1: should return initial state', () => {
expect(settingsReducer(undefined, { type: 'Default' }))
.toEqual(initialState);
});
test('CASE 2: should empty the state on LOGOUT_SUCCESS', () => {
expect(settingsReducer({ languageCode: 'en' }, { type: LOGOUT_SUCCESS }))
.toEqual(initialState);
});
test('CASE 3: should return settings on GET_SETTINGS_SUCCESS', () => {
const settings = { autoAcceptFriend: true, defaultPlaylistId: 123 };
const expectedState = { ...initialState, ...settings };
expect(settingsReducer(undefined, { type: GET_SETTINGS_SUCCESS, payload: { settings } }))
.toEqual(expectedState);
});
test('CASE 3: should return settings on SET_SETTINGS_SUCCESS', () => {
const settings = { defaultPlaylistId: 123 };
const existingState = { autoAcceptFriend: false, defaultPlaylistId: -1 };
const expectedState = { ...existingState, ...settings };
expect(settingsReducer(existingState, { type: SET_SETTINGS_SUCCESS, payload: { settings } }))
.toEqual(expectedState);
});
});