Skip to content

Commit 0499f98

Browse files
committed
add a minimal application with tests
1 parent a88cdb8 commit 0499f98

File tree

6 files changed

+75
-2
lines changed

6 files changed

+75
-2
lines changed

src/app/app.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<main>
2+
<h1 class="title">Hello from Angular !</h1>
3+
4+
<!-- Images (and assets) are parsed and loaded from within the public directory -->
5+
<img src="/img/logo.png">
6+
</main>
7+
<footer>
8+
<a ng-href="{{app.url}}">Webpack Angular Starter</a>
9+
</footer>

src/app/app.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
import angular from 'angular';
22

3-
angular.module('app', []);
3+
import '../style/app.css';
4+
5+
let app = () => {
6+
return {
7+
template: require('./app.html'),
8+
controller: 'AppCtrl',
9+
controllerAs: 'app'
10+
}
11+
};
12+
13+
class AppCtrl {
14+
constructor() {
15+
this.url = 'https://github.com/preboot/angular-webpack';
16+
}
17+
}
18+
19+
const MODULE_NAME = 'app';
20+
21+
angular.module(MODULE_NAME, [])
22+
.directive('app', app)
23+
.controller('AppCtrl', AppCtrl);
24+
25+
export default MODULE_NAME;

src/app/app.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import app from './app';
2+
3+
describe('app', () => {
4+
5+
describe('AppCtrl', () => {
6+
let ctrl;
7+
8+
beforeEach(() => {
9+
angular.mock.module(app);
10+
11+
angular.mock.inject(($controller) => {
12+
ctrl = $controller('AppCtrl', {});
13+
});
14+
});
15+
16+
it('should contain the starter url', () => {
17+
expect(ctrl.url).toBe('https://github.com/preboot/angular-webpack');
18+
});
19+
});
20+
});

src/public/img/logo.png

21 KB
Loading

src/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<base href="/">
99
</head>
1010
<body>
11-
Hello, World
11+
<app></app>
1212
</body>
1313
</html>

src/style/app.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* styles in src/style directory are applied to the whole page */
2+
body {
3+
background: #0147A7;
4+
color: #fff;
5+
}
6+
7+
a {
8+
color: #03A9F4;
9+
}
10+
11+
main {
12+
padding: 1em;
13+
font-family: Arial, Helvetica, sans-serif;
14+
text-align: center;
15+
margin-top: 50px;
16+
display: block;
17+
}
18+
19+
footer {
20+
text-align: center;
21+
font-size: 0.8em;
22+
}

0 commit comments

Comments
 (0)