mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 12:16:36 +00:00
Moved all server-related services to its own service provider
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import * as sinon from 'sinon';
|
||||
import reducer, {
|
||||
_selectServer,
|
||||
RESET_SELECTED_SERVER,
|
||||
selectServer,
|
||||
resetSelectedServer,
|
||||
RESET_SELECTED_SERVER,
|
||||
SELECT_SERVER,
|
||||
} from '../../../src/servers/reducers/selectedServer';
|
||||
import { RESET_SHORT_URL_PARAMS } from '../../../src/short-urls/reducers/shortUrlsListParams';
|
||||
@@ -45,7 +45,7 @@ describe('selectedServerReducer', () => {
|
||||
const dispatch = sinon.spy();
|
||||
const expectedDispatchCalls = 2;
|
||||
|
||||
_selectServer(ServersServiceMock)(serverId)(dispatch);
|
||||
selectServer(ServersServiceMock)(serverId)(dispatch);
|
||||
|
||||
expect(dispatch.callCount).toEqual(expectedDispatchCalls);
|
||||
expect(dispatch.firstCall.calledWith({ type: RESET_SHORT_URL_PARAMS })).toEqual(true);
|
||||
@@ -56,7 +56,7 @@ describe('selectedServerReducer', () => {
|
||||
});
|
||||
|
||||
it('invokes dependencies', () => {
|
||||
_selectServer(ServersServiceMock)(serverId)(() => {});
|
||||
selectServer(ServersServiceMock)(serverId)(() => {});
|
||||
|
||||
expect(ServersServiceMock.findServerById.callCount).toEqual(1);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as sinon from 'sinon';
|
||||
import { values } from 'ramda';
|
||||
import reducer, {
|
||||
_createServer,
|
||||
_deleteServer,
|
||||
_listServers,
|
||||
_createServers,
|
||||
createServer,
|
||||
deleteServer,
|
||||
listServers,
|
||||
createServers,
|
||||
FETCH_SERVERS,
|
||||
} from '../../../src/servers/reducers/server';
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('serverReducer', () => {
|
||||
|
||||
describe('listServers', () => {
|
||||
it('fetches servers and returns them as part of the action', () => {
|
||||
const result = _listServers(ServersServiceMock);
|
||||
const result = listServers(ServersServiceMock)();
|
||||
|
||||
expect(result).toEqual({ type: FETCH_SERVERS, servers });
|
||||
expect(ServersServiceMock.listServers.callCount).toEqual(1);
|
||||
@@ -51,7 +51,7 @@ describe('serverReducer', () => {
|
||||
describe('createServer', () => {
|
||||
it('adds new server and then fetches servers again', () => {
|
||||
const serverToCreate = { id: 'abc123' };
|
||||
const result = _createServer(ServersServiceMock, serverToCreate);
|
||||
const result = createServer(ServersServiceMock)(serverToCreate);
|
||||
|
||||
expect(result).toEqual({ type: FETCH_SERVERS, servers });
|
||||
expect(ServersServiceMock.listServers.callCount).toEqual(1);
|
||||
@@ -65,7 +65,7 @@ describe('serverReducer', () => {
|
||||
describe('deleteServer', () => {
|
||||
it('deletes a server and then fetches servers again', () => {
|
||||
const serverToDelete = { id: 'abc123' };
|
||||
const result = _deleteServer(ServersServiceMock, serverToDelete);
|
||||
const result = deleteServer(ServersServiceMock)(serverToDelete);
|
||||
|
||||
expect(result).toEqual({ type: FETCH_SERVERS, servers });
|
||||
expect(ServersServiceMock.listServers.callCount).toEqual(1);
|
||||
@@ -79,7 +79,7 @@ describe('serverReducer', () => {
|
||||
describe('createServer', () => {
|
||||
it('creates multiple servers and then fetches servers again', () => {
|
||||
const serversToCreate = values(servers);
|
||||
const result = _createServers(ServersServiceMock, serversToCreate);
|
||||
const result = createServers(ServersServiceMock)(serversToCreate);
|
||||
|
||||
expect(result).toEqual({ type: FETCH_SERVERS, servers });
|
||||
expect(ServersServiceMock.listServers.callCount).toEqual(1);
|
||||
|
||||
Reference in New Issue
Block a user