Fixed selectedServer reucer test

This commit is contained in:
Alejandro Celaya 2022-12-31 16:56:22 +01:00
parent 27099aa7fb
commit 37ac6cebc1

View file

@ -39,11 +39,12 @@ describe('selectedServerReducer', () => {
}); });
describe('selectServer', () => { describe('selectServer', () => {
const selectedServer = {
id: 'abc123',
};
const version = '1.19.0'; const version = '1.19.0';
const createGetStateMock = (id: string) => jest.fn().mockReturnValue({ servers: { [id]: selectedServer } }); const createGetStateMock = (id: string) => jest.fn().mockReturnValue({
servers: {
[id]: { id },
},
});
it.each([ it.each([
[version, version, `v${version}`], [version, version, `v${version}`],
@ -53,7 +54,7 @@ describe('selectedServerReducer', () => {
const id = uuid(); const id = uuid();
const getState = createGetStateMock(id); const getState = createGetStateMock(id);
const expectedSelectedServer = { const expectedSelectedServer = {
...selectedServer, id,
version: expectedVersion, version: expectedVersion,
printableVersion: expectedPrintableVersion, printableVersion: expectedPrintableVersion,
}; };
@ -84,7 +85,7 @@ describe('selectedServerReducer', () => {
it('dispatches error when health endpoint fails', async () => { it('dispatches error when health endpoint fails', async () => {
const id = uuid(); const id = uuid();
const getState = createGetStateMock(id); const getState = createGetStateMock(id);
const expectedSelectedServer = Mock.of<NonReachableServer>({ ...selectedServer, serverNotReachable: true }); const expectedSelectedServer = Mock.of<NonReachableServer>({ id, serverNotReachable: true });
health.mockRejectedValue({}); health.mockRejectedValue({});