mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-25 06:46:59 +00:00
- Updated import paths for Kugou and Kuwo instructions to reflect new directory structure. - Introduced new key management functionalities for Kugou, including key import and selection logic. - Added comprehensive instructions for both Kugou and Kuwo key handling across various platforms. - Implemented Redux selectors for managing staging and production keys for Kugou and Kuwo. - Enhanced documentation and tests for new features and key management processes.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { configureStore } from '@reduxjs/toolkit';
|
|
|
|
import settingsReducer, { settingsSlice } from '~/features/settings/settingsSlice';
|
|
import { selectKugouKey } from '../keyLookup';
|
|
|
|
function storeWithKugouKeys(keys: Record<string, string>) {
|
|
const base = settingsSlice.getInitialState();
|
|
return configureStore({
|
|
reducer: { settings: settingsReducer },
|
|
preloadedState: {
|
|
settings: {
|
|
...base,
|
|
production: {
|
|
...base.production,
|
|
kugou: { keys },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
describe('selectKugouKey', () => {
|
|
test('returns key for matching audioHash', () => {
|
|
const hash = 'a'.repeat(32);
|
|
const store = storeWithKugouKeys({ [hash]: 'ek' });
|
|
expect(selectKugouKey(store.getState(), { audioHash: hash } as never)).toBe('ek');
|
|
});
|
|
|
|
test('returns undefined for unknown hash or null header', () => {
|
|
const store = storeWithKugouKeys({ ['b'.repeat(32)]: 'ek' });
|
|
expect(selectKugouKey(store.getState(), { audioHash: 'c'.repeat(32) } as never)).toBeUndefined();
|
|
expect(selectKugouKey(store.getState(), null)).toBeUndefined();
|
|
});
|
|
});
|