mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-17 13:03:50 +00:00
Flatten model holding list of servers
This commit is contained in:
@@ -6,7 +6,6 @@ import reducer, {
|
||||
createServers,
|
||||
editServer,
|
||||
FETCH_SERVERS,
|
||||
FETCH_SERVERS_START,
|
||||
} from '../../../src/servers/reducers/server';
|
||||
|
||||
describe('serverReducer', () => {
|
||||
@@ -27,7 +26,7 @@ describe('serverReducer', () => {
|
||||
|
||||
describe('reducer', () => {
|
||||
it('returns servers when action is FETCH_SERVERS', () =>
|
||||
expect(reducer({}, { type: FETCH_SERVERS, list })).toEqual({ loading: false, list }));
|
||||
expect(reducer({}, { type: FETCH_SERVERS, list })).toEqual(list));
|
||||
});
|
||||
|
||||
describe('action creators', () => {
|
||||
@@ -39,9 +38,8 @@ describe('serverReducer', () => {
|
||||
it('fetches servers from local storage when found', async () => {
|
||||
await listServers(ServersServiceMock, axios)()(dispatch);
|
||||
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: FETCH_SERVERS_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, expectedFetchServersResult);
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, expectedFetchServersResult);
|
||||
expect(ServersServiceMock.listServers).toHaveBeenCalledTimes(1);
|
||||
expect(ServersServiceMock.createServer).not.toHaveBeenCalled();
|
||||
expect(ServersServiceMock.editServer).not.toHaveBeenCalled();
|
||||
@@ -90,9 +88,8 @@ describe('serverReducer', () => {
|
||||
|
||||
await listServers(NoListServersServiceMock, axios)()(dispatch);
|
||||
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: FETCH_SERVERS_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: FETCH_SERVERS, list: expectedList });
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: FETCH_SERVERS, list: expectedList });
|
||||
expect(NoListServersServiceMock.listServers).toHaveBeenCalledTimes(1);
|
||||
expect(NoListServersServiceMock.createServer).not.toHaveBeenCalled();
|
||||
expect(NoListServersServiceMock.editServer).not.toHaveBeenCalled();
|
||||
|
||||
Reference in New Issue
Block a user