How to use the ngx-speculoos.fakeSnapshot function in ngx-speculoos

To help you get started, we’ve selected a few ngx-speculoos 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 Ninja-Squad / globe42 / frontend / src / app / family-resolver.service.spec.ts View on Github external
it('should resolve family when displaying it', () => {
    const route = fakeSnapshot({ params: {}});
    expect(resolver.resolve(route)).toBe(family);
    expect(familyService.get).toHaveBeenCalledWith(54);
  });
});
github Ninja-Squad / globe42 / frontend / src / app / person-resolver.service.spec.ts View on Github external
it('should retrieve a person and refresh the current person', () => {
    const currentPersonService = TestBed.get(CurrentPersonService);
    const expectedResult = of({ firstName: 'John', lastName: 'Doe' } as PersonModel);

    spyOn(currentPersonService, 'refresh').and.returnValue(expectedResult);

    const resolver = TestBed.get(PersonResolverService);
    const routeSnapshot = fakeSnapshot({ params: { id: '42' } });
    const result = resolver.resolve(routeSnapshot);

    expect(result).toBe(expectedResult);
    expect(currentPersonService.refresh).toHaveBeenCalledWith(42);
  });
});
github Ninja-Squad / globe42 / frontend / src / app / per-unit-revenue-information-resolver.service.spec.ts View on Github external
it('should load when person ID is set on the current route', () => {
    const routeSnapshot = fakeSnapshot({
      params: {
        id: '42'
      }
    });

    const result = resolver.resolve(routeSnapshot);
    expect(result).toBe(info);
    expect(mockPerUnitRevenueInformationService.get).toHaveBeenCalledWith(42);
  });
github Ninja-Squad / globe42 / frontend / src / app / person-network-members / person-network-members.component.spec.ts View on Github external
beforeEach(async(() => {
    const member1: NetworkMemberModel = {
      id: 42,
      type: 'DOCTOR',
      text: 'Dr. No'
    };

    const member2: NetworkMemberModel = {
      id: 43,
      type: 'LAWYER',
      text: 'Dr. Yes'
    };

    route = fakeRoute({
      snapshot: fakeSnapshot({
        data: {
          members: [ member1, member2 ]
        }
      })
    });

    TestBed.configureTestingModule({
      declarations: [
        PersonNetworkMembersComponent,
        DisplayNetworkMemberTypePipe,
        ValidationDefaultsComponent,
        PageTitleDirective,
        FullnamePipe
      ],
      providers: [
        { provide: ActivatedRoute, useValue: route },
github Ninja-Squad / globe42 / frontend / src / app / person-resources / person-resources.component.spec.ts View on Github external
},
    {
      id: 15,
      type: { name: 'Electricité'},
      monthlyAmount: 50
    }
  ] as Array;

  const perUnitRevenueInformation: PerUnitRevenueInformationModel = {
    adultLikeCount: 4,
    childCount: 2,
    monoParental: true
  };

  const activatedRoute = fakeRoute({
    snapshot: fakeSnapshot({
      data: {
        incomes,
        charges,
        perUnitRevenueInformation
      }
    })
  });

  let tester: PersonResourcesTester;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [HttpClientModule, RouterTestingModule, GlobeNgbModule.forRoot()],
      declarations: [PersonResourcesComponent, PageTitleDirective, FullnamePipe],
      providers: [
        { provide: ActivatedRoute, useValue: activatedRoute },
github Ninja-Squad / globe42 / frontend / src / app / person-wedding-events / person-wedding-events.component.spec.ts View on Github external
date: '2001-02-28',
        type: 'WEDDING',
        location: 'ABROAD'
      },
      {
        id: 43,
        date: '2003-03-29',
        type: 'DIVORCE',
        location: 'FRANCE'
      }
    ];

    person = { id: 1, firstName: 'JB', lastName: 'Nizet' } as PersonModel;

    route = fakeRoute({
      snapshot: fakeSnapshot({data: {events}})
    });

    const weddingEventService: WeddingEventService =
      jasmine.createSpyObj('weddingEventService', ['list', 'create', 'delete']);
    const confirmService: ConfirmService =
      jasmine.createSpyObj('confirmService', ['confirm']);

    TestBed.configureTestingModule({
      declarations: [
        PersonWeddingEventsComponent,
        DisplayWeddingEventTypePipe,
        ValidationDefaultsComponent,
        DisplayLocationPipe,
        PageTitleDirective,
        FullnamePipe
      ],
github Ninja-Squad / globe42 / frontend / src / app / person-participations / person-participations.component.spec.ts View on Github external
beforeEach(() => {
    participations = [
      {
        id: 42,
        activityType: 'MEAL'
      }
    ];

    person = { id: 1, firstName: 'JB', lastName: 'Nizet' } as PersonModel;

    route = fakeRoute({
      snapshot: fakeSnapshot({data: {participations}})
    });
    currentPersonService = { snapshot: person } as CurrentPersonService;
  });
github Ninja-Squad / globe42 / frontend / src / app / person-memberships / person-memberships.component.spec.ts View on Github external
beforeEach(async(() => {
    jasmine.clock().mockDate(DateTime.fromISO('2018-04-30T15:30:00').toJSDate());

    person = {
      id: 1
    } as PersonModel;

    memberships = [];

    const route = fakeRoute({
      snapshot: fakeSnapshot({
        data: {
          memberships
        }
      })
    });

    TestBed.configureTestingModule({
      declarations: [
        PersonMembershipsComponent,
        DisplayPaymentModePipe,
        ValidationDefaultsComponent,
        PageTitleDirective,
        FullnamePipe
      ],
      providers: [
        { provide: ActivatedRoute, useFactory: () => route },
github Ninja-Squad / globe42 / frontend / src / app / person-family / person-family.component.spec.ts View on Github external
beforeEach(async(() => {
    route = fakeRoute({
      snapshot: fakeSnapshot({
        data: {
        }
      })
    });

    TestBed.configureTestingModule({
      declarations: [PersonFamilyComponent, SituationComponent, PageTitleDirective, FullnamePipe],
      providers: [
        FamilyService,
        ConfirmService,
        { provide: ActivatedRoute, useFactory: () => route }
      ],
      imports: [
        HttpClientTestingModule,
        RouterTestingModule,
        GlobeNgbModule.forRoot()
github Ninja-Squad / globe42 / frontend / src / app / profile / profile.component.spec.ts View on Github external
beforeEach(async(() => {
    profile = {
      login: 'joe',
      admin: true,
      email: 'joe@nowhere.com',
      taskAssignmentEmailNotificationEnabled: true
    } as ProfileModel;

    const route = fakeRoute({
      snapshot: fakeSnapshot({
        data: { profile }
      })
    });

    TestBed.configureTestingModule({
      declarations: [ ProfileComponent ],
      imports: [
        GlobeNgbModule.forRoot(),
        HttpClientTestingModule,
        RouterTestingModule,
        ReactiveFormsModule,
        ValdemortModule
      ],
      providers: [
        { provide: ActivatedRoute, useFactory: () => route }
      ]

ngx-speculoos

Helps writing Angular unit tests

MIT
Latest version published 12 days ago

Package Health Score

72 / 100
Full package analysis