Skip to content

Instantly share code, notes, and snippets.

@coelhoadler
Last active August 21, 2018 14:24
Show Gist options
  • Select an option

  • Save coelhoadler/269904de9f9a27af4c31e979297666b8 to your computer and use it in GitHub Desktop.

Select an option

Save coelhoadler/269904de9f9a27af4c31e979297666b8 to your computer and use it in GitHub Desktop.
Create a blank karma component body
"Print karma component body": {
"prefix": "kacom",
"body": [
"import { ComponentFixture, TestBed } from '@angular/core/testing';",
"import { RouterTestingModule } from '@angular/router/testing';",
"import { HttpClientTestingModule } from '@angular/common/http/testing'; \n",
"describe('$1', () => {",
"\tlet fixture: ComponentFixture<$1>;",
"\tlet component: $1; \n",
"\tbeforeEach(() => {",
"\t\tTestBed.configureTestingModule({",
"\t\t\tdeclarations: [ ],",
"\t\t\timports: [",
"\t\t\t\tRouterTestingModule.withRoutes([]),",
"\t\t\t\tHttpClientTestingModule",
"\t\t\t]",
"\t\t}).compileComponents(); \n",
"\t\tfixture = TestBed.createComponent($1);",
"\t\tcomponent = fixture.componentInstance; \n",
"\t}); \n",
"\tit('should be created', () => {",
"\t\texpect(component).toBeTruthy();",
"\t}); \n",
"});",
],
"description": "Print a blank body of karma component test."
}
"Print karma service test body": {
"prefix": "kaserv",
"body": [
"import { TestBed, inject } from '@angular/core/testing';",
"import { PathService } from '../api/path.service';",
"import { HttpClientTestingModule } from '@angular/common/http/testing'; \n",
"describe('$1', () => {",
"\tlet service;",
"\tbeforeEach(() => {",
"\t\tTestBed.configureTestingModule({",
"\t\t\timports: [",
"\t\t\t\tHttpClientTestingModule",
"\t\t\t],",
"\t\t\tproviders: [",
"\t\t\t\t$2,",
"\t\t\t\tCryptographyService,",
"\t\t\t\tPathService,",
"\t\t\t\tAuth",
"\t\t\t]",
"\t\t});",
"\t});\n",
"\tbeforeEach(inject([$2],",
"\t(auth: $2) => {",
"\t\tservice = auth;",
"\t}));\n",
"\tit('should be create', () => {",
"\t\texpect(service).toBeTruthy();",
"\t});",
"});",
],
"description": "Print a blank body of karma service test."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment