mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* consistent error handling * Display server errors in InviteUserForm * Handle errors in Form component * Refactors query form * creates KolideAce component * Renders QueryForm from query page and manage hosts page * Moves ace editor and select targets dropdown to query form * Render base errors in Form HOC * LoginPage and ForgotPasswordPage server errors * Ensure unique key for user blocks * Adds base error to login form and forgot password form * Adds base error to query form * Adds base error to Pack Form * Adds errors to confirm invite form * Adds clearErrors action * clear errors when confirm invite page unmounts * Handle errors in the App Setting page * Handle server errors in the User Settings Page * Handle server errors in the User Management Page
85 lines
2.1 KiB
JavaScript
85 lines
2.1 KiB
JavaScript
import expect from 'expect';
|
|
|
|
import reducer, { initialState } from './reducer';
|
|
import {
|
|
configFailure,
|
|
configSuccess,
|
|
hideBackgroundImage,
|
|
showBackgroundImage,
|
|
loadConfig,
|
|
} from './actions';
|
|
|
|
describe('App - reducer', () => {
|
|
it('sets the initial state', () => {
|
|
expect(reducer(undefined, { type: 'SOME_ACTION' })).toEqual(initialState);
|
|
});
|
|
|
|
context('showBackgroundImage action', () => {
|
|
it('shows the background image', () => {
|
|
expect(reducer(initialState, showBackgroundImage)).toEqual({
|
|
config: {},
|
|
error: {},
|
|
loading: false,
|
|
showBackgroundImage: true,
|
|
});
|
|
});
|
|
});
|
|
|
|
context('hideBackgroundImage action', () => {
|
|
it('hides the background image', () => {
|
|
const state = {
|
|
...initialState,
|
|
showBackgroundImage: true,
|
|
};
|
|
expect(reducer(state, hideBackgroundImage)).toEqual({
|
|
config: {},
|
|
error: {},
|
|
loading: false,
|
|
showBackgroundImage: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
context('loadConfig action', () => {
|
|
it('sets the state to loading', () => {
|
|
expect(reducer(initialState, loadConfig)).toEqual({
|
|
config: {},
|
|
error: {},
|
|
loading: true,
|
|
showBackgroundImage: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
context('configSuccess action', () => {
|
|
it('sets the config in state', () => {
|
|
const config = { name: 'Kolide' };
|
|
const loadingConfigState = {
|
|
...initialState,
|
|
loading: true,
|
|
};
|
|
expect(reducer(loadingConfigState, configSuccess(config))).toEqual({
|
|
config,
|
|
error: {},
|
|
loading: false,
|
|
showBackgroundImage: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
context('configFailure action', () => {
|
|
it('sets the error in state', () => {
|
|
const error = 'Unable to get config';
|
|
const loadingConfigState = {
|
|
...initialState,
|
|
loading: true,
|
|
};
|
|
expect(reducer(loadingConfigState, configFailure(error))).toEqual({
|
|
config: {},
|
|
error,
|
|
loading: false,
|
|
showBackgroundImage: false,
|
|
});
|
|
});
|
|
});
|
|
});
|