Skip to content

Instantly share code, notes, and snippets.

@rexar1988
Forked from benjamincharity/mockActivatedRoute.ts
Created February 10, 2020 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexar1988/11537c4e7a2482888ec200809528b5b7 to your computer and use it in GitHub Desktop.
Save rexar1988/11537c4e7a2482888ec200809528b5b7 to your computer and use it in GitHub Desktop.
Mock ActivatedRoute with params, data and snapshot.
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MdToolbarModule,
],
providers: [
{
provide: Router,
useClass: MockRouter,
},
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) => fn({
company: COMPANY,
}),
},
params: {
subscribe: (fn: (value: Params) => void) => fn({
tab: 0,
}),
},
snapshot: {
url: [
{
path: 'foo',
},
{
path: 'bar',
},
{
path: 'baz',
},
],
},
},
},
],
})
.overrideComponent(ConversationsComponent, {
set: {
template: '',
}
});
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment