uruha / next-with-ts

Next.js for boiler plate to easy development.
MIT License
21 stars 2 forks source link

Feature/modify actions and template #77

Closed doutori closed 4 years ago

doutori commented 4 years ago

Todo

Generated Code Samples

Added file

actions/sample/sample.test.ts

/* eslint-env jest */
import { GET_SAMPLE, UPDATE_SAMPLE } from '~/constant';
import { sampleActions } from '~/actions';
import { SampleState } from '~/stateTypes';

describe('Sample actions', () => {
    it('should create get sample action', () => {
        const expectedAction = {
            type: GET_SAMPLE
        };

        expect(sampleActions.getSample()).toEqual(expectedAction);
    });

    it('should create update sample action', () => {
        const expectedPayload: SampleState = {
            value: 'hoge',
        };
        const expectedAction = {
            type: UPDATE_SAMPLE,
            payload: {
                value: expectedPayload.value,
            }
        };

        expect(sampleActions.updateSample(expectedPayload)).toEqual(
            expectedAction
        );
    });
});

Updated (+++ lines are added)

actions/index.ts

+++ import * as sampleActions from './sample';
import * as accountActions from './account';
import * as counterActions from './counter';

// eslint-disable-next-line
export {
+++    sampleActions,
    accountActions,
    counterActions,
};