Files
2025-08-06 13:49:11 +08:00

38 lines
1.2 KiB
JavaScript

/* global describe: true, test:true, expect:true */
import { fujifilmCategories as fujifilmCategoriesReducer, initialState } from '~/reducers/fujifilmCategories';
import {
GET_FUJIFILM_CHILD_CATEGORY_PROPDUCTS_SUCCESS,
} from '~/store/actionTypes';
describe('fujifilmCategories reducer', () => {
test('CASE 1: should return initial state', () => {
expect(fujifilmCategoriesReducer(undefined, { type: 'Default' }))
.toEqual(initialState);
});
test('CASE 2: should return correct state when type is GET_FUJIFILM_CHILD_CATEGORY_PROPDUCTS_SUCCESS', () => {
const categoryId = 1;
const products = [{
ProductCode: '1',
}, {
ProductCode: '2',
}];
const serviceType = 'MailOrder';
const childCategoryProducts = {
1: [{
ProductCode: '1',
}, {
ProductCode: '2',
}],
};
const stateResult = fujifilmCategoriesReducer(initialState, {
type: GET_FUJIFILM_CHILD_CATEGORY_PROPDUCTS_SUCCESS,
payload: { categoryId, products, serviceType },
});
expect(stateResult).toHaveProperty('childCategoryProducts');
expect(stateResult.childCategoryProducts).toEqual(childCategoryProducts);
expect(stateResult).toHaveProperty('meta');
});
});