mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-19 21:16:18 +00:00
Created ServersService test
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import ServersService from '../../servers/services/ServersService';
|
||||
import serversService from '../../servers/services/ServersService';
|
||||
import { resetShortUrlParams } from '../../short-urls/reducers/shortUrlsListParams'
|
||||
import { curry } from 'ramda';
|
||||
|
||||
@@ -21,10 +21,10 @@ export default function reducer(state = defaultState, action) {
|
||||
|
||||
export const resetSelectedServer = () => ({ type: RESET_SELECTED_SERVER });
|
||||
|
||||
export const _selectServer = (ShlinkApiClient, ServersService, serverId) => dispatch => {
|
||||
export const _selectServer = (ShlinkApiClient, serversService, serverId) => dispatch => {
|
||||
dispatch(resetShortUrlParams());
|
||||
|
||||
const selectedServer = ServersService.findServerById(serverId);
|
||||
const selectedServer = serversService.findServerById(serverId);
|
||||
ShlinkApiClient.setConfig(selectedServer);
|
||||
|
||||
dispatch({
|
||||
@@ -32,4 +32,4 @@ export const _selectServer = (ShlinkApiClient, ServersService, serverId) => disp
|
||||
selectedServer
|
||||
})
|
||||
};
|
||||
export const selectServer = curry(_selectServer)(ShlinkApiClient, ServersService);
|
||||
export const selectServer = curry(_selectServer)(ShlinkApiClient, serversService);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ServersService from '../services/ServersService';
|
||||
import serversService from '../services/ServersService';
|
||||
import { curry } from 'ramda';
|
||||
|
||||
export const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS';
|
||||
@@ -12,26 +12,26 @@ export default function reducer(state = {}, action) {
|
||||
}
|
||||
}
|
||||
|
||||
export const _listServers = ServersService => ({
|
||||
export const _listServers = serversService => ({
|
||||
type: FETCH_SERVERS,
|
||||
servers: ServersService.listServers(),
|
||||
servers: serversService.listServers(),
|
||||
});
|
||||
export const listServers = () => _listServers(ServersService);
|
||||
export const listServers = () => _listServers(serversService);
|
||||
|
||||
export const _createServer = (ServersService, server) => {
|
||||
ServersService.createServer(server);
|
||||
return _listServers(ServersService);
|
||||
export const _createServer = (serversService, server) => {
|
||||
serversService.createServer(server);
|
||||
return _listServers(serversService);
|
||||
};
|
||||
export const createServer = curry(_createServer)(ServersService);
|
||||
export const createServer = curry(_createServer)(serversService);
|
||||
|
||||
export const _deleteServer = (ServersService, server) => {
|
||||
ServersService.deleteServer(server);
|
||||
return _listServers(ServersService);
|
||||
export const _deleteServer = (serversService, server) => {
|
||||
serversService.deleteServer(server);
|
||||
return _listServers(serversService);
|
||||
};
|
||||
export const deleteServer = curry(_deleteServer)(ServersService);
|
||||
export const deleteServer = curry(_deleteServer)(serversService);
|
||||
|
||||
export const _createServers = (ServersService, servers) => {
|
||||
ServersService.createServers(servers);
|
||||
return _listServers(ServersService);
|
||||
export const _createServers = (serversService, servers) => {
|
||||
serversService.createServers(servers);
|
||||
return _listServers(serversService);
|
||||
};
|
||||
export const createServers = curry(_createServers)(ServersService);
|
||||
export const createServers = curry(_createServers)(serversService);
|
||||
|
||||
@@ -30,4 +30,5 @@ export class ServersService {
|
||||
);
|
||||
}
|
||||
|
||||
export default new ServersService(Storage);
|
||||
const serversService = new ServersService(Storage);
|
||||
export default serversService;
|
||||
|
||||
Reference in New Issue
Block a user