我一直在为交换案例编写测试案例,有2个测试案例。我收到此皮棉错误消息,提示Update or refactor this function so that its implementation does not duplicate other
。由于切换案例包含相似的案例,因此我需要帮助来重新编写我的代码。]
这是我的2例
it('case 1', () => {
data = merge(Run.String_Window, {
0: '3',
});
expect(service.getName('year-1', element, frequency)).toEqual(serve);
});
it('case 2', () => {
data = merge(Run.String_Window, {
0: '5',
});
expect(service.getName('year-2', element, frequency)).toEqual(serve);
});
const testCases = [
{
desc: 'case 1',
input: { /* ... */ },
expected: { /* ... */ }
}, {
desc: 'case 2',
input: { /* ... */ },
expected: { /* ... */ }
}
// case 3,4,5....
];
testCases.forEach(tc => {
it(tc.desc, () => {
//...
expect(/*...*/).toEqual(tc.expected);
});
});