blob: 0518e7b94c511bb46e71b972f71612eb036b1e9e [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import {clearNewStatementFormAction, setNewStatementProgressAction, submitNewStatementAction} from "../../actions";
import {IStatementInfoForm, IStatementInformationFormValue} from "../../model";
import {newStatementFormReducer} from "./new-statement-form.reducer";
describe("newStatementFormReducer", () => {
const value = {} as IStatementInformationFormValue;
it("should update the form value on submit", () => {
const initialState = undefined;
const action = submitNewStatementAction({value});
const state = newStatementFormReducer(initialState, action);
expect(state).toEqual({value, isLoading: true, error: undefined});
});
it("should clear the form", () => {
const initialState = {} as IStatementInfoForm;
const action = clearNewStatementFormAction();
const state = newStatementFormReducer(initialState, action);
expect(state).toEqual(undefined);
});
it("should update the progress information", () => {
const action = setNewStatementProgressAction({isLoading: true, error: undefined});
const state = newStatementFormReducer({value}, action);
expect(state).toEqual({value, isLoading: true, error: undefined});
});
});