This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest'; | |
import { of } from 'rxjs'; | |
import { AwesomeEntityStore } from './entity.store'; | |
import { EntityDataService } from './entity-data.service'; | |
import { EntityService } from './entity.service'; | |
describe('Service: EntityService', () => { | |
let dataService: SpyObject<EntityDataService>; | |
let store: SpyObject<AwesomeEntityStore>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Observable } from 'rxjs'; | |
import { tap } from 'rxjs/operators'; | |
import { AwesomeEntity } from './awesome-entity.model'; | |
import { AwesomeEntityStore } from './entity.store'; | |
import { EntityDataService } from './entity-data.service'; | |
@Injectable() | |
export class EntityService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { AwesomeEntity } from './awesome-entity.model'; | |
@Injectable() | |
export class EntityDataService { | |
constructor(private _http: HttpClient) {} | |
getEntities() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createHTTPFactory, SpectatorHTTP } from '@netbasal/spectator/jest'; | |
import { HTTPMethod } from '@netbasal/spectator'; | |
import { EntityDataService } from './entity-data.service'; | |
describe('Service: EntityDataService', () => { | |
const httpService: () => SpectatorHTTP<EntityDataService> = createHTTPFactory< | |
EntityDataService | |
>(EntityDataService); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface AwesomeEntity { | |
id: number; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest'; | |
import { MatSnackBar } from '@angular/material/snack-bar'; | |
import { NotificationService } from './notification.service'; | |
describe('Service: NotificationService', () => { | |
let snackBar: SpyObject<MatSnackBar>; | |
let spectator: SpectatorService<NotificationService> = createService({ | |
service: NotificationService, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { MatSnackBar } from '@angular/material/snack-bar'; | |
@Injectable({ providedIn: 'root' }) | |
export class NotificationService { | |
constructor(private _snackBar: MatSnackBar) {} | |
notify(message: string, duration = 7000): void { | |
this._snackBar.open(message, 'CLOSE', { duration }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Spectator, SpyObject, createTestComponentFactory } from '@netbasal/spectator/jest'; | |
import { of } from 'rxjs'; | |
import { StatefulComponent } from './stateful.component'; | |
import { AwesomeEntitiesQuery } from './+state'; | |
describe('Component: StatefulComponent', () => { | |
let query: SpyObject<AwesomeEntitiesQuery>; | |
let spectator: Spectator<StatefulComponent>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest'; | |
import { of } from 'rxjs'; | |
import { AwesomeEntityStore } from './entity.store'; | |
import { EntityDataService } from './entity-data.service'; | |
import { EntityService } from './entity.service'; | |
describe('Service: EntityService', () => { | |
let dataService: SpyObject<EntityDataService>; | |
let store: SpyObject<AwesomeEntityStore>; |