Skip to content
Snippets Groups Projects
Select Git revision
  • 5811a787e60efd4ed6925b1c24b92947b85dd3d5
  • main default protected
  • OZG-7970-AlfaCodeFlow
  • OZG-8279-restore-missing-tooltips
  • OZG-8073-date-component
  • OZG-7856_schadcode_scanner
  • OZG-7985-Statistik-Datenfreigabe
  • OZG-8305-Create-webpack-sbom
  • tooltip-improvements
  • ods-remove-class-inputs
  • release-info
  • release-administration
  • release
  • OZG-7714-UpgradeKeycloakDependencyTo25
  • OZG-8086-Admin-Datenanfrage-erstellen
  • OZG-8086-Datenanfrage-Umbenennung
  • mongodb-7-0-16-e2e
  • OZG-6220-Bescheid-speichern-ohne-Postfach
  • OZG-7922-KeycloakOperatorExceptions
  • OZG-8142-poc-cards
  • OZG-8086-E2E
  • 1.11.0-info
  • 1.11.0-administration
  • 2.26.0-alfa
  • 1.10.0-info
  • 1.10.0-administration
  • 2.25.0-alfa
  • 1.9.0-info
  • 1.9.0-administration
  • 2.24.0-alfa
  • 1.8.0-info
  • 1.8.0-administration
  • 2.23.0-alfa
  • 1.7.0-info
  • 1.7.0-administration
  • 2.22.0-alfa
  • 1.6.0-info
  • 1.6.0-administration
  • 2.21.0-alfa
  • 1.5.0-info
  • 1.5.0-administration
41 results

authentication.service.ts

Blame
  • resource.service.spec.ts 18.04 KiB
    import { Mock, mock, useFromMock } from '@alfa-client/test-utils';
    import { Observable, lastValueFrom, of, throwError } from 'rxjs';
    import { ResourceService } from './resource.service';
    import { ResourceRepository } from './resource.repository';
    import { LinkRelationName, ResourceServiceConfig, SaveResourceData } from './resource.model';
    import { Resource, getUrl } from '@ngxp/rest';
    import { createDummyResource } from 'libs/tech-shared/test/resource';
    import {
      StateResource,
      createEmptyStateResource,
      createErrorStateResource,
      createStateResource,
    } from './resource.util';
    import { fakeAsync, tick } from '@angular/core/testing';
    import { singleCold, singleHot } from './marbles';
    import { HttpErrorResponse } from '@angular/common/http';
    import { createProblemDetail } from 'libs/tech-shared/test/error';
    import { HttpError, ProblemDetail } from '../tech.model';
    import { cold } from 'jest-marbles';
    
    import * as ResourceUtil from './resource.util';
    
    describe('ResourceService', () => {
      let service: ResourceService<Resource, Resource>;
      let config: ResourceServiceConfig<Resource>;
    
      let repository: Mock<ResourceRepository>;
    
      const configResource: Resource = createDummyResource();
      const configStateResource: StateResource<Resource> = createStateResource(configResource);
      const configStateResource$: Observable<StateResource<Resource>> = of(configStateResource);
    
      const deleteLinkRel: string = 'dummyDeleteLinkRel';
      const editLinkRel: string = 'dummyEditLinkRel';
      const getLinkRel: LinkRelationName = 'dummyGetLinkRel';
    
      beforeEach(() => {
        config = {
          resource: configStateResource$,
          getLinkRel,
          deleteLinkRel,
          editLinkRel,
        };
        repository = mock(ResourceRepository);
    
        service = new ResourceService(config, useFromMock(repository));
      });
    
      it('should be created', () => {
        expect(service).toBeTruthy();
      });
    
      describe('get', () => {
        const stateResource: StateResource<Resource> = createStateResource(configResource);
    
        beforeEach(() => {
          service.stateResource.next(stateResource);
    
          service.handleNullConfigResource = jest.fn();
          service.handleConfigResource = jest.fn();
          service.handleConfigResourceChanged = jest.fn();
          service.shouldFilter = jest.fn().mockReturnValue(true);
        });
    
        it('should handle config resource changed', fakeAsync(() => {
          service.get().subscribe();
          tick();
    
          expect(service.handleConfigResourceChanged).toHaveBeenCalledWith(configResource);
        }));