Skip to content

Commit 7334ce8

Browse files
committed
Add routing module
1 parent 8eaaa79 commit 7334ce8

11 files changed

+93
-34
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-electron",
3-
"version": "1.3.0",
3+
"version": "1.3.",
44
"description": "Angular 4 with Electron (Typescript + SASS + Hot Reload)",
55
"homepage": "https://github.com/maximegris/angular-electron",
66
"author": {
@@ -17,14 +17,14 @@
1717
"private": true,
1818
"scripts": {
1919
"ng": "ng",
20+
"lint": "ng lint",
2021
"start": "webpack --watch",
2122
"test": "karma start ./karma.conf.js",
22-
"lint": "ng lint",
2323
"e2e": "protractor ./protractor.conf.js",
24-
"build": "webpack --display-error-details && copyfiles main.js dist",
25-
"build:prod": "cross-env NODE_ENV='production' npm run build",
2624
"prepree2e": "npm start",
2725
"pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
26+
"build": "webpack --display-error-details && copyfiles main.js dist",
27+
"build:prod": "cross-env NODE_ENV='production' npm run build",
2828
"electron:serve": "electron . --serve",
2929
"electron:dev": "npm run build && electron dist/main.js",
3030
"electron:prod": "npm run build:prod && electron dist/main.js",

src/app/app-routing.module.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { HomeComponent } from './home/home.component';
2+
import { NgModule } from '@angular/core';
3+
import { Routes, RouterModule } from '@angular/router';
4+
5+
const routes: Routes = [
6+
{
7+
path: '',
8+
component: HomeComponent
9+
}
10+
];
11+
12+
@NgModule({
13+
imports: [RouterModule.forRoot(routes)],
14+
exports: [RouterModule]
15+
})
16+
export class AppRoutingModule { }

src/app/app.component.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
<h1 class="title">
2-
{{title}}
3-
</h1>
4-
1+
<router-outlet></router-outlet>

src/app/app.component.scss

-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
.title {
2-
color: black;
3-
margin:0;
4-
padding:50px 20px;
5-
background: url(../assets/background.jpg) no-repeat center fixed;
6-
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
7-
background-size: cover; /* version standardisée */
8-
}

src/app/app.component.spec.ts

-13
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,4 @@ describe('AppComponent', () => {
1616
const app = fixture.debugElement.componentInstance;
1717
expect(app).toBeTruthy();
1818
}));
19-
20-
it(`should have as title 'app works!'`, async(() => {
21-
const fixture = TestBed.createComponent(AppComponent);
22-
const app = fixture.debugElement.componentInstance;
23-
expect(app.title).toEqual('app works!');
24-
}));
25-
26-
it('should render title in a h1 tag', async(() => {
27-
const fixture = TestBed.createComponent(AppComponent);
28-
fixture.detectChanges();
29-
const compiled = fixture.debugElement.nativeElement;
30-
expect(compiled.querySelector('h1').textContent).toContain('app works!');
31-
}));
3219
});

src/app/app.component.ts

-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ import * as childProcess from 'child_process';
88
styleUrls: ['./app.component.scss']
99
})
1010
export class AppComponent {
11-
title = `App works !`;
12-
1311
constructor() {
1412
// Check if electron is correctly injected (see externals in webpack.config.js)
1513
console.log('c', ipcRenderer);
1614
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
1715
console.log('c', childProcess);
18-
1916
}
2017
}

src/app/app.module.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ import { FormsModule } from '@angular/forms';
44
import { HttpModule } from '@angular/http';
55

66
import { AppComponent } from './app.component';
7+
import { HomeComponent } from './home/home.component';
8+
9+
import { AppRoutingModule } from './app-routing.module';
710

811
@NgModule({
912
declarations: [
10-
AppComponent
13+
AppComponent,
14+
HomeComponent
1115
],
1216
imports: [
1317
BrowserModule,
1418
FormsModule,
15-
HttpModule
19+
HttpModule,
20+
AppRoutingModule
1621
],
1722
providers: [],
1823
bootstrap: [AppComponent]

src/app/home/home.component.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1 class="title">
2+
{{title}}
3+
</h1>

src/app/home/home.component.scss

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.title {
2+
color: black;
3+
margin:0;
4+
padding:50px 20px;
5+
background: url(../../assets/background.jpg) no-repeat center fixed;
6+
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
7+
background-size: cover; /* version standardisée */
8+
}

src/app/home/home.component.spec.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HomeComponent } from './home.component';
4+
5+
describe('HomeComponent', () => {
6+
let component: HomeComponent;
7+
let fixture: ComponentFixture<HomeComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ HomeComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(HomeComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
26+
it(`should have as title 'App works !'`, async(() => {
27+
const fixture = TestBed.createComponent(HomeComponent);
28+
const app = fixture.debugElement.componentInstance;
29+
expect(app.title).toEqual('aApp works !');
30+
}));
31+
32+
it('should render title in a h1 tag', async(() => {
33+
const fixture = TestBed.createComponent(HomeComponent);
34+
fixture.detectChanges();
35+
const compiled = fixture.debugElement.nativeElement;
36+
expect(compiled.querySelector('h1').textContent).toContain('App works !');
37+
}));
38+
});

src/app/home/home.component.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-home',
5+
templateUrl: './home.component.html',
6+
styleUrls: ['./home.component.scss']
7+
})
8+
export class HomeComponent implements OnInit {
9+
title = `App works !`;
10+
11+
constructor() { }
12+
13+
ngOnInit() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)