Last active
May 10, 2018 14:15
-
-
Save codesandtags/f8fd6ec492f5f048431b450ab4ff4f84 to your computer and use it in GitHub Desktop.
Live Templates for Angular Projects and Testing
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
<template name="jdes" value="describe('When $DESCRIBE_NAME$ is invoke', () => { it('should $SHOULD_NAME$', () => { $END$ }); });" description="Jasmine Describe" toReformat="false" toShortenFQNames="true"> | |
<variable name="DESCRIBE_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="SHOULD_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_SCRIPT" value="true" /> | |
<option name="TypeScript" value="true" /> | |
</context> | |
</template> | |
<template name="jit" value="it('should $SHOULD_NAME$', () => { $END$ });" description="It case" toReformat="false" toShortenFQNames="true"> | |
<variable name="SHOULD_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_SCRIPT" value="true" /> | |
<option name="TypeScript" value="true" /> | |
</context> | |
</template> | |
<template name="jtc" value="import { async, ComponentFixture, getTestBed, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { DummyComponent } from '../../mocks/dummy.component.spec'; import { Router } from '@angular/router'; describe('$COMPONENT_NAME$Component', () => { let component: $COMPONENT_NAME$Component;$END$ let fixture: ComponentFixture<$COMPONENT_NAME$Component>; let router: Router; let injector: TestBed; beforeEach( async(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule.withRoutes([{path: 'somepath', component: DummyComponent}]) ] declarations: [$COMPONENT_NAME$Component], providers: [] }).compileComponents(); }) ); beforeEach(() => { fixture = TestBed.createComponent($COMPONENT_NAME$Component); component = fixture.componentInstance; injector = getTestBed(); router = injector.get(Router); fixture.detectChanges(); }); afterAll(() => { component = null; fixture = null; injector = null; router = null; }); describe('First case', () => { it('should ', () => { }); }); }); " description="Component Unit Test Template" toReformat="false" toShortenFQNames="true"> | |
<variable name="COMPONENT_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_SCRIPT" value="true" /> | |
<option name="TypeScript" value="true" /> | |
</context> | |
</template> | |
<template name="jts" value="import { async, getTestBed, TestBed } from '@angular/core/testing'; import { Router } from '@angular/router'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; describe('$SERVICE_NAME$Service', () => { let myService: $SERVICE_NAME$Service;$END$ let injector: TestBed; let httpMock: HttpTestingController; let router: Router; beforeEach( async(() => { TestBed.configureTestingModule({ imports: [ HttpClientTestingModule, RouterTestingModule.withRoutes([{path: 'somepath', component: DummyComponent}]) ], providers: [ $SERVICE_NAME$Service ] }); }) ); beforeEach(() => { injector = getTestBed(); myService = injector.get($SERVICE_NAME$Service); httpMock = injector.get(HttpTestingController); router = injector.get(Router); }); afterAll(() => { injector = null; myService = null; httpMock = null; router = null; }); afterEach(() => { httpMock.verify(); }); }); " description="Service Unit Test Template" toReformat="false" toShortenFQNames="true"> | |
<variable name="SERVICE_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_SCRIPT" value="true" /> | |
<option name="TypeScript" value="true" /> | |
</context> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You just need to copy and paste the content over this configuration live templates in Intellij. 😄