How to use the ts-mockito.spy function in ts-mockito

To help you get started, we’ve selected a few ts-mockito examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intershop / intershop-pwa / src / app / shared / product / components / product-add-to-compare / product-add-to-compare.component.spec.ts View on Github external
it('should detect errors on emitter using spy', () => {
    const emitter = spy(component.compareToggle);
    component.toggleCompare();

    verify(emitter.emit()).once();
  });
});
github intershop / intershop-pwa / src / app / extensions / quoting / shared / product / components / product-add-to-quote-dialog / product-add-to-quote-dialog.component.spec.ts View on Github external
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",
        }
      `);
    });
  });
github intershop / intershop-pwa / src / app / extensions / quoting / shared / quote / quote-edit / quote-edit.component.spec.ts View on Github external
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",
        }
      `);
    });
  });
github intershop / intershop-pwa / src / app / pages / account-profile-user / account-profile-user / account-profile-user.component.spec.ts View on Github external
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();
  });
github intershop / intershop-pwa / src / app / shared / address-forms / components / customer-address-form / customer-address-form.component.spec.ts View on Github external
it('should throw cancel event when cancel is clicked', () => {
    const emitter = spy(component.cancel);

    component.cancelForm();

    verify(emitter.emit()).once();
  });
github intershop / intershop-pwa / src / app / shared / address-forms / components / address-form-container / address-form-container.component.spec.ts View on Github external
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);
github intershop / intershop-pwa / src / app / extensions / quoting / shared / quote / quote-edit / quote-edit.component.spec.ts View on Github external
it('should throw submitQuoteRequest event when submit is clicked', () => {
      const emitter = spy(component.submitQuoteRequest);

      component.submit();
      verify(emitter.emit()).once();
    });
github intershop / intershop-pwa / src / app / pages / product / product-detail-actions / product-detail-actions.component.spec.ts View on Github external
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();
  });
});
github intershop / intershop-pwa / src / app / core / models / category / category.mapper.spec.ts View on Github external
beforeEach(async(() => {
    TestBed.configureTestingModule({ imports: [StoreModule.forRoot({ configuration: configurationReducer })] });
    categoryMapper = TestBed.get(CategoryMapper);
    imageMapper = spy(TestBed.get(ImageMapper));
  }));
github intershop / intershop-pwa / src / app / core / store / shopping / products / products.effects.spec.ts View on Github external
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) }));
  });