Skip to content

Commit

Permalink
Add routing module
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegris committed May 5, 2017
1 parent 8eaaa79 commit 7334ce8
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 34 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-electron",
"version": "1.3.0",
"version": "1.3.",
"description": "Angular 4 with Electron (Typescript + SASS + Hot Reload)",
"homepage": "https://github.com/maximegris/angular-electron",
"author": {
Expand All @@ -17,14 +17,14 @@
"private": true,
"scripts": {
"ng": "ng",
"lint": "ng lint",
"start": "webpack --watch",
"test": "karma start ./karma.conf.js",
"lint": "ng lint",
"e2e": "protractor ./protractor.conf.js",
"build": "webpack --display-error-details && copyfiles main.js dist",
"build:prod": "cross-env NODE_ENV='production' npm run build",
"prepree2e": "npm start",
"pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
"build": "webpack --display-error-details && copyfiles main.js dist",
"build:prod": "cross-env NODE_ENV='production' npm run build",
"electron:serve": "electron . --serve",
"electron:dev": "npm run build && electron dist/main.js",
"electron:prod": "npm run build:prod && electron dist/main.js",
Expand Down
16 changes: 16 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { HomeComponent } from './home/home.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
component: HomeComponent
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
5 changes: 1 addition & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<h1 class="title">
{{title}}
</h1>

<router-outlet></router-outlet>
8 changes: 0 additions & 8 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
.title {
color: black;
margin:0;
padding:50px 20px;
background: url(../assets/background.jpg) no-repeat center fixed;
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
background-size: cover; /* version standardisée */
}
13 changes: 0 additions & 13 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,4 @@ describe('AppComponent', () => {
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));

it(`should have as title 'app works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));

it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
3 changes: 0 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import * as childProcess from 'child_process';
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = `App works !`;

constructor() {
// Check if electron is correctly injected (see externals in webpack.config.js)
console.log('c', ipcRenderer);
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
console.log('c', childProcess);

}
}
9 changes: 7 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';

import { AppRoutingModule } from './app-routing.module';

@NgModule({
declarations: [
AppComponent
AppComponent,
HomeComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
HttpModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
Expand Down
3 changes: 3 additions & 0 deletions src/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1 class="title">
{{title}}
</h1>
8 changes: 8 additions & 0 deletions src/app/home/home.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.title {
color: black;
margin:0;
padding:50px 20px;
background: url(../../assets/background.jpg) no-repeat center fixed;
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
background-size: cover; /* version standardisée */
}
38 changes: 38 additions & 0 deletions src/app/home/home.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { HomeComponent } from './home.component';

describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it(`should have as title 'App works !'`, async(() => {
const fixture = TestBed.createComponent(HomeComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('aApp works !');
}));

it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(HomeComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('App works !');
}));
});
16 changes: 16 additions & 0 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
title = `App works !`;

constructor() { }

ngOnInit() {
}

}

0 comments on commit 7334ce8

Please sign in to comment.