moveColumns(shifter: number, index: number) {
const columnFields = this.form.get('sizes') as FormArray;
let newIndex = index shifter;
if (newIndex === -1) {
newIndex = columnFields.length - 1;
} else if (newIndex === columnFields.length) {
newIndex = 0;
}
const currentGroup = columnFields.at(index);
columnFields.removeAt(index);
columnFields.insert(newIndex, currentGroup);
}
我的困難是它們都在函式變數內部,而不是組件全域變數。
uj5u.com熱心網友回復:
您需要存根表單物件,然后驗證函式中發生的更改
// in your test beforeEach
mockComponent.form = new FormArray({sizes: new FormControl());
// And in your function, you can update this form object and validate it
it('should test my function', () => {
const modifiedForm = {} // Add the final result after the function executes
expect(mockComponent.form).toEquals(modifiedForm);
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/414957.html
標籤:
