How to use the @spartacus/core.ANONYMOUS_CONSENT_STATUS.GIVEN function in @spartacus/core

To help you get started, we’ve selected a few @spartacus/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 SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / myaccount / consent-management / components / consent-form / consent-management-form.component.spec.ts View on Github external
it('should set consentGiven according to the state of the provided consent', () => {
          component.consent = { consentState: ANONYMOUS_CONSENT_STATUS.GIVEN };
          component.isAnonymousConsentsEnabled = true;
          component.ngOnInit();
          expect(component.consentGiven).toEqual(true);
        });
      });
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / shared / components / anonymous-consents / dialog / anonymous-consent-dialog.component.spec.ts View on Github external
describe('rejectAll', () => {
    const mockConsent: AnonymousConsent[] = [
      {
        templateCode: mockTemplates[0].id,
        consentState: ANONYMOUS_CONSENT_STATUS.GIVEN,
      },
      {
        templateCode: mockTemplates[1].id,
        consentState: ANONYMOUS_CONSENT_STATUS.GIVEN,
      },
    ];
    describe('when a required consent is present', () => {
      it('should skip it', () => {
        anonymousConsentsConfig.anonymousConsents.requiredConsents = [
          mockTemplates[0].id,
        ];
        spyOn(component, 'closeModal').and.stub();
        spyOn(component['subscriptions'], 'add').and.callThrough();
        spyOn(anonymousConsentsService, 'isConsentGiven').and.returnValues(
          true,
          true
        );
        spyOn(anonymousConsentsService, 'withdrawConsent').and.stub();

        component.templates$ = of(mockTemplates);
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / myaccount / consent-management / components / consent-form / consent-management-form.component.ts View on Github external
ngOnInit(): void {
    if (this.isAnonymousConsentsEnabled && this.consent) {
      this.consentGiven = Boolean(
        this.consent.consentState === ANONYMOUS_CONSENT_STATUS.GIVEN
      );
    } else {
      if (this.consentTemplate && this.consentTemplate.currentConsent) {
        if (this.consentTemplate.currentConsent.consentWithdrawnDate) {
          this.consentGiven = false;
        } else if (this.consentTemplate.currentConsent.consentGivenDate) {
          this.consentGiven = true;
        }
      }
    }
  }
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / user / register / register.component.spec.ts View on Github external
it('should call anonymousConsentsService.isConsentGiven', () => {
      spyOn(anonymousConsentService, 'isConsentGiven').and.stub();
      const mockConsent: AnonymousConsent = {
        consentState: ANONYMOUS_CONSENT_STATUS.GIVEN,
      };
      component.isConsentGiven(mockConsent);
      expect(anonymousConsentService.isConsentGiven).toHaveBeenCalledWith(
        mockConsent
      );
    });
  });
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / shared / components / anonymous-consents / dialog / anonymous-consent-dialog.component.spec.ts View on Github external
describe('rejectAll', () => {
    const mockConsent: AnonymousConsent[] = [
      {
        templateCode: mockTemplates[0].id,
        consentState: ANONYMOUS_CONSENT_STATUS.GIVEN,
      },
      {
        templateCode: mockTemplates[1].id,
        consentState: ANONYMOUS_CONSENT_STATUS.GIVEN,
      },
    ];
    describe('when a required consent is present', () => {
      it('should skip it', () => {
        anonymousConsentsConfig.anonymousConsents.requiredConsents = [
          mockTemplates[0].id,
        ];
        spyOn(component, 'closeModal').and.stub();
        spyOn(component['subscriptions'], 'add').and.callThrough();
        spyOn(anonymousConsentsService, 'isConsentGiven').and.returnValues(
          true,
          true