Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test](sqle/store): add missing unit test file #180

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion packages/sqle/src/store/globalRuleTemplate/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import reducers, { updateGlobalSelectRuleTemplate } from '.';
import reducers, {
updateGlobalSelectRuleTemplate,
updateRuleManagerActiveSegmentedKey
} from '.';
import { RuleManagerSegmentedKey } from '../../page/RuleManager/index.type';
import { ruleTemplateListData } from '../../page/RuleTemplate/__testData__';

Expand All @@ -24,4 +27,19 @@ describe('store/globalRuleTemplate', () => {
);
expect(newState.selectGlobalRuleTemplate).toBe(ruleTemplateListData[0]);
});

test('should execute action updateRuleManagerActiveSegmentedKey', () => {
const state = {
selectGlobalRuleTemplate: null,
modalStatus: {},
activeSegmentedKey: RuleManagerSegmentedKey.CustomRule
};

const newState = reducers(
state,
updateRuleManagerActiveSegmentedKey(RuleManagerSegmentedKey.CustomRule)
);

expect(newState).toEqual(newState);
});
});
43 changes: 43 additions & 0 deletions packages/sqle/src/store/sqleManagement/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SqlManageStatusEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum';
import reducers, {
SqleManagementState,
updateSqlIdList,
updateSqleManagement
} from '.';

const initialState: SqleManagementState = {
modalStatus: {},
selectSqleManagement: null,
selectSqlIdList: null
};

describe('store/sqleManagement', () => {
test('should create action', () => {
expect(updateSqleManagement(null)).toEqual({
payload: null,
type: 'sqleManagement/updateSqleManagement'
});
});

test('should exc updateSqleManagement', () => {
const state = {
id: 1,
status: SqlManageStatusEnum.manual_audited
};
const newState = reducers(initialState, updateSqleManagement(state));
expect(newState.selectSqleManagement).toEqual(state);
});

test('should exc updateSqlIdList', () => {
const state = [
{
id: 1
},
{
id: 2
}
];
const newState = reducers(initialState, updateSqlIdList(state));
expect(newState.selectSqlIdList).toEqual(state);
});
});
2 changes: 1 addition & 1 deletion packages/sqle/src/store/sqleManagement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { commonModalReducer } from '../common';
import { ISqlManage } from '@actiontech/shared/lib/api/sqle/service/common';

// SqleManagement
type SqleManagementState = {
export type SqleManagementState = {
modalStatus: ModalStatus;
selectSqleManagement: null | ISqlManage;
selectSqlIdList: ISqlManage[] | null;
Expand Down
Loading