Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #4 from cloudliner/step/3
Step 3 CI: 継続的インテグレーション編
  • Loading branch information
cloudliner committed Mar 23, 2018
2 parents fa94a71 + cf57f46 commit a736d7b
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 8 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
@@ -0,0 +1,31 @@
dist: trusty
sudo: required
language: node_js
node_js:
- 8.9.4
addons:
chrome: stable
cache:
apt: true
bundler: true
directories:
- node_modules
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
before_script:
- ng lint
- ng test --single-run --code-coverage
- ng e2e
script:
- ng build --prod
after_success:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
deploy:
provider: firebase
token:
secure: adXjXAiklHyh0IZkpyxi7SJdSGDaE63RdeyWjq0mWjy44gwRSYVkloOBBa2/RSdKIaamzlh0D7CAtZVgLWUjoPRPVDjdPnTXvDMNKjSR0XnMOcPx4PSFulVUWymYixtc1GaSeck/DH6kH5KNFdy3vITJAnyH4Bm05+DgS4/KGvQjwDnXWQ2U3gU4fJ2B44Lu+/pk1WWTlnL6JwXfKrPVp+IvHRfhYYKBvMCPwxhC65Ut4I5i7GKccqS95oalu9ws5H9YSRUR/PDrm1hdU3VxcK22NnHhd9qSZl/wVt3xfdcqnBxN8y2w5g5xBcEcMeJ1f4E19xZUt7Y2VdmTlpEDgmlEUljetxgVXDTe3poHPNJVKjQVM8w0uGmsB8yfoQcL5YsdH3eBTe9OuubprMhE+pJUlmI5mnFMc+3Qtz3mRUIrlUGGJXVcYQxKOGtm49fEhjUX+axzcUETIJt0jN17DKDmBdDigKVty5DSQSA+dKRKq+uy2aYKpITRebJ/gOUjyGDcJQinA0Lf8qjhVdTs/xxQMWOI06PNg1T6QUOcxBeC+8U25UQzIdpTzuSL8IFPUayQp23Wwm6oPw6g9V7+TEo3Cb2DiASAbXmO2ABmlFcKNdYsFA4vRZ8yGQS4te/h8Xpqkqx0lyqTn7xaWFP0OZIqYOxuD/SPlolFYR68+IY=
skip_cleanup: true
on:
branch: master
12 changes: 12 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
6 changes: 4 additions & 2 deletions e2e/app.e2e-spec.ts
@@ -1,4 +1,5 @@
import { AppPage } from './app.po';
import { browser } from 'protractor';

describe('dac-angular App', () => {
let page: AppPage;
Expand All @@ -7,8 +8,9 @@ describe('dac-angular App', () => {
page = new AppPage();
});

it('should display welcome message', () => {
it('should display first chat message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to app!');
browser.sleep(5000);
expect(page.getFirstMessage()).toEqual('Hello, World!');
});
});
4 changes: 2 additions & 2 deletions e2e/app.po.ts
Expand Up @@ -5,7 +5,7 @@ export class AppPage {
return browser.get('/');
}

getParagraphText() {
return element(by.css('app-root h1')).getText();
getFirstMessage() {
return element(by.css('app-root ul li')).getText();
}
}
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -35,6 +35,7 @@
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"coveralls": "^3.0.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
Expand Down
1 change: 1 addition & 0 deletions protractor.conf.js
Expand Up @@ -24,5 +24,6 @@ exports.config = {
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
browser.ignoreSynchronization = true;
}
};
27 changes: 23 additions & 4 deletions src/app/app.component.spec.ts
@@ -1,27 +1,46 @@
import { TestBed, async } from '@angular/core/testing';
import { AngularFirestore } from 'angularfire2/firestore';
import { environment } from '../environments/environment';
import { AppComponent } from './app.component';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/from';

const timeline = [[
{ message: 'Hello, Test!' }
]];
const data = Observable.from(timeline);
const collectionStub = {
valueChanges: jasmine.createSpy('valueChanges').and.returnValue(data)
};
const angularFiresotreStub = {
collection: jasmine.createSpy('collection').and.returnValue(collectionStub)
};

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
providers: [
{ provide: AngularFirestore, useValue: angularFiresotreStub }
]
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
it('should have timeline', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
expect(app.timeline).toBeDefined();
}));
it('should render title in a h1 tag', async(() => {
it('should render message in a li tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
expect(compiled.querySelector('ul>li').textContent).toContain('Hello, Test!');
}));
});

0 comments on commit a736d7b

Please sign in to comment.