46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
|
import { AnyAction } from 'redux';
|
||
|
|
||
|
import {
|
||
|
CAROUSEL_AVATAR_REQUEST,
|
||
|
CAROUSEL_AVATAR_SUCCESS,
|
||
|
CAROUSEL_AVATAR_FAIL,
|
||
|
} from 'soapbox/actions/carousels';
|
||
|
|
||
|
import reducer from '../carousels';
|
||
|
|
||
|
describe('carousels reducer', () => {
|
||
|
it('should return the initial state', () => {
|
||
|
expect(reducer(undefined, {} as AnyAction)).toEqual({
|
||
|
avatars: [],
|
||
|
isLoading: false,
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('CAROUSEL_AVATAR_REQUEST', () => {
|
||
|
it('sets "isLoading" to "true"', () => {
|
||
|
const initialState = { isLoading: false, avatars: [] };
|
||
|
const action = { type: CAROUSEL_AVATAR_REQUEST };
|
||
|
expect(reducer(initialState, action).isLoading).toEqual(true);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('CAROUSEL_AVATAR_SUCCESS', () => {
|
||
|
it('sets the next state', () => {
|
||
|
const initialState = { isLoading: true, avatars: [] };
|
||
|
const action = { type: CAROUSEL_AVATAR_SUCCESS, payload: [45] };
|
||
|
const result = reducer(initialState, action);
|
||
|
|
||
|
expect(result.isLoading).toEqual(false);
|
||
|
expect(result.avatars).toEqual([45]);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('CAROUSEL_AVATAR_FAIL', () => {
|
||
|
it('sets "isLoading" to "true"', () => {
|
||
|
const initialState = { isLoading: true, avatars: [] };
|
||
|
const action = { type: CAROUSEL_AVATAR_FAIL };
|
||
|
expect(reducer(initialState, action).isLoading).toEqual(false);
|
||
|
});
|
||
|
});
|
||
|
});
|