Skip to content

Commit 0b5b1b9

Browse files
committed
add exception spec
1 parent c3f6726 commit 0b5b1b9

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

app/common/exception.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
21
export default function exception(logger) {
3-
var service = {
4-
catcher: catcher
2+
return {
3+
catcher
54
};
6-
return service;
75

86
function catcher(message) {
97
return function (reason) {

tests/common/exception.spec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
describe('exception', ()=> {
2+
3+
let exceptionInstance, loggerMock;
4+
5+
beforeEach(()=> {
6+
angular.mock.module(function ($provide) {
7+
$provide.service('logger', function () {
8+
this.error = jasmine.createSpy('error');
9+
});
10+
});
11+
12+
angular.mock.module('espackApp');
13+
});
14+
15+
describe('#ctor', ()=> {
16+
17+
beforeEach(()=> {
18+
_inject();
19+
});
20+
21+
it('should exist', ()=> {
22+
expect(!!exceptionInstance).toBe(true);
23+
});
24+
25+
it('should define catcher property', function () {
26+
27+
expect(exceptionInstance.catcher).toBeDefined();
28+
expect(typeof exceptionInstance.catcher).toBe('function');
29+
});
30+
31+
});
32+
33+
function _inject() {
34+
inject((exception, logger) => {
35+
loggerMock = logger;
36+
exceptionInstance = exception;
37+
});
38+
}
39+
});

0 commit comments

Comments
 (0)