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 detect errors on emitter using spy', () => {
const emitter = spy(component.compareToggle);
component.toggleCompare();
verify(emitter.emit()).once();
});
});
it('should throw updateSubmitQuoteRequest event when submit is clicked and the form values were changed before ', () => {
const emitter = spy(component.updateSubmitQuoteRequest);
component.form.value.displayName = 'DNAME';
component.form.value.description = 'DESC';
component.form.markAsDirty();
component.submit();
verify(emitter.emit(anything())).once();
const [arg] = capture(emitter.emit).last();
expect(arg).toMatchInlineSnapshot(`
Object {
"description": "DESC",
"displayName": "DNAME",
}
`);
});
});
it('should throw updateSubmitQuoteRequest event when submit is clicked and the form values were changed before ', () => {
const emitter = spy(component.updateSubmitQuoteRequest);
component.form.value.displayName = 'DNAME';
component.form.value.description = 'DESC';
component.form.markAsDirty();
component.submit();
verify(emitter.emit(anything())).once();
const [arg] = capture(emitter.emit).last();
expect(arg).toMatchInlineSnapshot(`
Object {
"description": "DESC",
"displayName": "DNAME",
}
`);
});
});
it('should emit updateUserProfile event if form is valid', () => {
const eventEmitter$ = spy(component.updateUserProfile);
component.countryCode = 'US';
component.currentUser = { firstName: 'Patricia', lastName: 'Miller' } as User;
fixture.detectChanges();
component.submit();
verify(eventEmitter$.emit(anything())).once();
});
it('should throw cancel event when cancel is clicked', () => {
const emitter = spy(component.cancel);
component.cancelForm();
verify(emitter.emit()).once();
});
it('should react on country changes', () => {
const storeSpy$ = spy(store$);
const newCountry = 'BG';
const parentForm = new FormGroup({
countryCodeSwitch: new FormControl('DE'),
address: new FormGroup({}),
});
component.parentForm = parentForm;
const changes: SimpleChanges = {
parentForm: new SimpleChange(undefined, component.parentForm, false),
};
fixture.detectChanges();
component.ngOnChanges(changes);
component.parentForm.get('countryCodeSwitch').setValue(newCountry);
it('should throw submitQuoteRequest event when submit is clicked', () => {
const emitter = spy(component.submitQuoteRequest);
component.submit();
verify(emitter.emit()).once();
});
it('should emit "product to compare" event when compare link is clicked', () => {
const eventEmitter$ = spy(component.productToCompare);
fixture.detectChanges();
element.querySelector("[data-testing-id='compare-sku'] a").click();
verify(eventEmitter$.emit()).once();
});
});
beforeEach(async(() => {
TestBed.configureTestingModule({ imports: [StoreModule.forRoot({ configuration: configurationReducer })] });
categoryMapper = TestBed.get(CategoryMapper);
imageMapper = spy(TestBed.get(ImageMapper));
}));
shopping: combineReducers(shoppingReducers),
locale: localeReducer,
},
}),
],
providers: [
ProductsEffects,
provideMockActions(() => actions$),
{ provide: ProductsService, useFactory: () => instance(productsServiceMock) },
{ provide: PRODUCT_LISTING_ITEMS_PER_PAGE, useValue: 3 },
],
});
effects = TestBed.get(ProductsEffects);
store$ = TestBed.get(Store);
router = spy(TestBed.get(Router));
location = TestBed.get(Location);
store$.dispatch(new SetProductListingPageSize({ itemsPerPage: TestBed.get(PRODUCT_LISTING_ITEMS_PER_PAGE) }));
});