How to use the @shopgate/pwa-core/classes/Event.addCallbackSpy function in @shopgate/pwa-core

To help you get started, we’ve selected a few @shopgate/pwa-core 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 shopgate / pwa / libraries / engage / core / actions / __tests__ / grantPermissions.spec.js View on Github external
it('should resolve with FALSE when called with an invalid permissionId', async () => {
    const granted = await grantPermissions({ permissionId: 'unknownId' })(dispatch);
    expect(granted).toBe(false);
    expect(getAppPermissions).not.toHaveBeenCalled();
    expect(requestAppPermissions).not.toHaveBeenCalled();
    expect(dispatch).not.toHaveBeenCalled();
    expect(openAppSettings).not.toHaveBeenCalled();
    expect(event.addCallbackSpy).not.toHaveBeenCalled();
    expect(logger.error).toHaveBeenCalledTimes(1);
  });
github shopgate / pwa / libraries / engage / core / actions / __tests__ / grantPermissions.spec.js View on Github external
it('should resolve with TRUE when the permissions are granted', async () => {
    const granted = await grantPermissions({ permissionId })(dispatch);

    expect(granted).toBe(true);
    expect(getAppPermissions).toHaveBeenCalledWith([permissionId]);
    expect(requestAppPermissions).not.toHaveBeenCalled();
    expect(dispatch).not.toHaveBeenCalled();
    expect(openAppSettings).not.toHaveBeenCalled();
    expect(event.addCallbackSpy).not.toHaveBeenCalled();
  });
github shopgate / pwa / libraries / tracking / subscriptions / setup.spec.js View on Github external
it('should call the expected commands', () => {
      callback({ dispatch });

      expect(registerEvents).toHaveBeenCalledTimes(1);
      expect(registerEvents).toHaveBeenCalledWith([
        APP_EVENT_VIEW_DID_APPEAR,
        APP_EVENT_VIEW_DID_DISAPPEAR,
      ]);
      expect(event.addCallbackSpy).toHaveBeenCalledTimes(2);
      expect(event.addCallbackSpy).toHaveBeenCalledWith(
        APP_EVENT_VIEW_DID_APPEAR,
        expect.any(Function)
      );
      expect(event.addCallbackSpy).toHaveBeenCalledWith(
        APP_EVENT_VIEW_DID_DISAPPEAR,
        expect.any(Function)
      );
    });
github shopgate / pwa / libraries / tracking / subscriptions / setup.spec.js View on Github external
it('should call the expected commands', () => {
      callback({ dispatch });

      expect(registerEvents).toHaveBeenCalledTimes(1);
      expect(registerEvents).toHaveBeenCalledWith([
        APP_EVENT_VIEW_DID_APPEAR,
        APP_EVENT_VIEW_DID_DISAPPEAR,
      ]);
      expect(event.addCallbackSpy).toHaveBeenCalledTimes(2);
      expect(event.addCallbackSpy).toHaveBeenCalledWith(
        APP_EVENT_VIEW_DID_APPEAR,
        expect.any(Function)
      );
      expect(event.addCallbackSpy).toHaveBeenCalledWith(
        APP_EVENT_VIEW_DID_DISAPPEAR,
        expect.any(Function)
      );
    });