Skip to content

Commit

Permalink
test: add library consumption test
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Mar 28, 2018
1 parent 461cd0b commit af68853
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/e2e/tests/generate/library/library-basic.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {ng} from '../../../utils/process';
import { ng, silentNpm } from '../../../utils/process';
import { expectFileToMatch } from '../../../utils/fs';
import { useCIChrome } from '../../../utils/project';


export default function() {
export default function () {
return ng('generate', 'library', 'my-lib')
.then(() => expectFileToMatch('angular.json', /\"my-lib\":/));

// TODO: enable once generating Angular v6 projects
// this is due to the service using `providedIn`
// .then(() => useCIChrome())
// .then(() => ng('test', 'my-lib', '--watch=false'));
.then(() => expectFileToMatch('angular.json', /\"my-lib\":/))
.then(() => useCIChrome('my-lib'))
.then(() => silentNpm('install'))
.then(() => ng('build', 'my-lib'))
.then(() => ng('test', 'my-lib', '--watch=false'));
}
46 changes: 46 additions & 0 deletions tests/e2e/tests/generate/library/library-consumption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ng, silentNpm } from '../../../utils/process';
import { writeFile } from '../../../utils/fs';

export default function () {
return ng('generate', 'library', 'my-lib')
.then(() => silentNpm('install'))
.then(() => ng('build', 'my-lib'))
.then(() => writeFile('./projects/test-project/src/app/app.module.ts', `
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MyLibModule } from 'my-lib';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
MyLibModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`))
.then(() => writeFile('./projects/test-project/src/app/app.component.ts', `
import { Component } from '@angular/core';
import { MyLibService } from 'my-lib';
@Component({
selector: 'app-root',
template: '<my-lib></my-lib>'
})
export class AppComponent {
title = 'app';
constructor(myLibService: MyLibService) {
console.log(myLibService);
}
}
`))
.then(() => ng('build', 'test-project'))
.then(() => ng('build', 'test-project', '--prod'));
}

0 comments on commit af68853

Please sign in to comment.