Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should remove the correct expression form the list", () => {
component.baseCommand = [
new SBDraft2ExpressionModel("one"),
new SBDraft2ExpressionModel("two"),
new SBDraft2ExpressionModel("three")
];
component.model = mockModel;
component.ngOnChanges();
fixture.detectChanges();
component.removeBaseCommand(1);
fixture.detectChanges();
fixture.whenStable().then(() => {
expect((component.form.get("list") as FormArray).controls.length).toEqual(2, "Did not remove baseCommand");
expect((component.form.get("list") as FormArray).controls[0].value.toString()).toEqual("one");
expect((component.form.get("list") as FormArray).controls[1].value.toString()).toEqual("three");
});
it("should remove the correct expression form the list", () => {
component.baseCommand = [
new SBDraft2ExpressionModel("one"),
new SBDraft2ExpressionModel("two"),
new SBDraft2ExpressionModel("three")
];
component.model = mockModel;
component.ngOnChanges();
fixture.detectChanges();
component.removeBaseCommand(1);
fixture.detectChanges();
fixture.whenStable().then(() => {
expect((component.form.get("list") as FormArray).controls.length).toEqual(2, "Did not remove baseCommand");
expect((component.form.get("list") as FormArray).controls[0].value.toString()).toEqual("one");
expect((component.form.get("list") as FormArray).controls[1].value.toString()).toEqual("three");
});
it("should remove the correct expression form the list", () => {
component.baseCommand = [
new SBDraft2ExpressionModel("one"),
new SBDraft2ExpressionModel("two"),
new SBDraft2ExpressionModel("three")
];
component.model = mockModel;
component.ngOnChanges();
fixture.detectChanges();
component.removeBaseCommand(1);
fixture.detectChanges();
fixture.whenStable().then(() => {
expect((component.form.get("list") as FormArray).controls.length).toEqual(2, "Did not remove baseCommand");
expect((component.form.get("list") as FormArray).controls[0].value.toString()).toEqual("one");
expect((component.form.get("list") as FormArray).controls[1].value.toString()).toEqual("three");
});
});
beforeEach(fakeAsync(() => {
fixture = TestBed.createComponent(ToolStreamsComponent);
component = fixture.componentInstance;
v1Expr = new V1ExpressionModel("expression");
d2Expr = new SBDraft2ExpressionModel("expression");
v1Model = new V1CommandLineToolModel();
sbDraft2Model = new SBDraft2CommandLineToolModel();
tick();
}));
addExpressionModel(): void {
const newCmd = {
id: Guid.generate(),
model: new SBDraft2ExpressionModel("")
};
this.form.addControl(newCmd.id, new FormControl(newCmd.model, [Validators.required, CustomValidators.cwlModel]));
this.formList.push(newCmd);
this.form.markAsTouched();
}
private addExpressionModel(): void {
const newCmd = {
id: this.guidService.generate(),
model: new SBDraft2ExpressionModel("")
};
this.form.addControl(newCmd.id, new FormControl(newCmd.model, [Validators.required, CustomValidators.cwlModel]));
this.formList.push(newCmd);
this.form.markAsTouched();
}
addEntry(): void {
const newEntry = {
id: Guid.generate(),
model: {
key: "",
value: new SBDraft2ExpressionModel(null, ""),
readonly: false
}
};
this.keyValueFormList.push(newEntry);
this.form.addControl(newEntry.id, new FormControl(newEntry.model));
}
beforeEach(fakeAsync(() => {
fixture = TestBed.createComponent(BaseCommandListComponent);
component = fixture.componentInstance;
d2expr = new SBDraft2ExpressionModel("expression");
mockModel = {
baseCommand: [d2expr, d2expr, d2expr],
addBaseCommand: () => {
},
updateBaseCommand: () => {
}
};
fixture.detectChanges();
tick();
}));