How to use the ts-mockito.anyString 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 / basket / components / basket-validation-results / basket-validation-results.component.spec.ts View on Github external
it('should delete an item if called', () => {
    when(checkoutFacadeMock.deleteBasketItem(anyString())).thenReturn(undefined);

    component.deleteItem('4713');

    verify(checkoutFacadeMock.deleteBasketItem('4713')).once();
  });
});
github intershop / intershop-pwa / src / app / extensions / quoting / store / quote / quote.effects.spec.ts View on Github external
it('should map to action of type LoadQuotes if SubmitQuoteRequestSuccess action triggered', () => {
      const action = new SubmitQuoteRequestSuccess(anyString());
      const completion = new quoteActions.LoadQuotes();
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.loadQuotesAfterChangeSuccess$).toBeObservable(expected$);
    });
github intershop / intershop-pwa / src / app / core / store / checkout / basket / basket-items.effects.spec.ts View on Github external
it('should map invalid request to action of type AddItemsToBasketFail', () => {
      when(basketServiceMock.addItemsToBasket(anyString(), anything())).thenReturn(throwError({ message: 'invalid' }));

      store$.dispatch(
        new basketActions.LoadBasketSuccess({
          basket: {
            id: 'BID',
            lineItems: [],
          } as Basket,
        })
      );

      const items = [{ sku: 'invalid', quantity: 1, unit: 'pcs.' }];
      const action = new basketActions.AddItemsToBasket({ items });
      const completion = new basketActions.AddItemsToBasketFail({ error: { message: 'invalid' } as HttpError });
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / identity / forgot-password / forgot-password.component.spec.ts View on Github external
it('should submit when email or username is specified', fakeAsync(() => {
    const env = new TestEnvironment();
    when(env.mockedIdentityService.forgotPassword(anything())).thenResolve(true);
    env.fixture.detectChanges();

    env.setInputValue(env.userInput, 'user');
    env.clickSubmitButton();

    verify(env.mockedIdentityService.forgotPassword(deepEqual('user'))).once();
    verify(env.mockedNoticeService.show(anyString())).once();
    expect().nothing();
    flush();
  }));
github intershop / intershop-pwa / src / app / core / store / orders / orders.effects.spec.ts View on Github external
it('should dispatch a LoadOrderFail action if a load error occurs', () => {
      when(orderServiceMock.getOrderByToken(anyString(), anyString())).thenReturn(throwError({ message: 'error' }));

      const action = new orderActions.LoadOrderByAPIToken({ apiToken: 'dummy', orderId: order.id });
      const completion = new orderActions.LoadOrderFail({ error: { message: 'error' } as HttpError });
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.loadOrderByAPIToken$).toBeObservable(expected$);
    });
  });
github intershop / intershop-pwa / src / app / core / services / user / user.service.spec.ts View on Github external
it("should update the business customer when 'updateCustomer' is called with type 'SMBCustomer'", done => {
      when(apiServiceMock.put(anyString(), anything())).thenReturn(of({}));

      const customer = {
        customerNo: '4711',
        companyName: 'xyz',
        type: 'SMBCustomer',
        isBusinessCustomer: true,
      } as Customer;

      userService.updateCustomer(customer).subscribe(() => {
        verify(apiServiceMock.put('customers/-', anything())).once();
        done();
      });
    });
  });
github intershop / intershop-pwa / src / app / core / store / checkout / basket / basket-promotion-code.effects.spec.ts View on Github external
it('should map invalid request to action of type AddPromotionCodeToBasketFail', () => {
      when(basketServiceMock.addPromotionCodeToBasket(anyString(), anyString())).thenReturn(
        throwError({ message: 'invalid' })
      );

      const code = 'CODE';
      const action = new basketActions.AddPromotionCodeToBasket({ code });
      const completion = new basketActions.AddPromotionCodeToBasketFail({ error: { message: 'invalid' } as HttpError });
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.addPromotionCodeToBasket$).toBeObservable(expected$);
    });
  });
github intershop / intershop-pwa / src / app / extensions / quoting / store / quote-request / quote-request.effects.spec.ts View on Github external
beforeEach(() => {
      store$.dispatch(new LoginUserSuccess({ customer }));
      store$.dispatch(new LoadCompanyUserSuccess({ user: { email: 'test' } as User }));
      store$.dispatch(
        new quoteRequestActions.LoadQuoteRequestsSuccess({ quoteRequests: [{ id: 'QRID' } as QuoteRequestData] })
      );
      store$.dispatch(new quoteRequestActions.SelectQuoteRequest({ id: 'QRID' }));

      when(quoteRequestServiceMock.removeItemFromQuoteRequest(anyString(), anyString())).thenReturn(of('QRID'));
    });
github intershop / intershop-pwa / src / app / extensions / quoting / store / quote-request / quote-request.effects.spec.ts View on Github external
basket: {
            id: 'BID',
            lineItems: [
              {
                id: 'BIID',
                name: 'NAME',
                position: 1,
                quantity: { value: 1 },
                productSKU: 'SKU',
              } as LineItem,
            ],
            payment: undefined,
          } as Basket,
        })
      );
      when(quoteRequestServiceMock.addProductToQuoteRequest(anyString(), anything())).thenReturn(of('QRID'));
    });