Skip to content

Commit 3624eef

Browse files
committed
test(library): Added unit tests for the whole source code
- Added tests for the animation presets, components, models, services, and modules - Removed temporary test file - Updated tslint rules
1 parent 9793773 commit 3624eef

21 files changed

+3574
-193
lines changed

karma-angular.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
// General configuration
4-
Error.stackTraceLimit = 0; // Alternatively set to 'Infinity'
4+
Error.stackTraceLimit = Infinity; // Alternatively set to 'Infinity'
55
jasmine.DEFAULT_TIMEOUT_INTERVAL = 3000;
66
__karma__.loaded = function() {}; // Canceles Karma's synchronous start (will be started later manually)
77

karma.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ module.exports = function( config ) {
226226
'/node_modules': '/base/node_modules',
227227
'/src': '/base/src',
228228
'/demo': '/base/demo'
229-
}
229+
},
230+
231+
browserNoActivityTimeout: 1000000 // FOR DEBUGGING REASONS
230232

231233
};
232234

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { NotifierAnimationPresetKeyframes } from '../models/notifier-animation.model';
2+
import { fade } from './../animation-presets/fade.animation-preset';
3+
4+
/**
5+
* Fade animation preset - Unit Test
6+
*/
7+
export function main(): void {
8+
9+
describe( 'Fade Animation Preset', () => {
10+
11+
describe( '(show)', () => {
12+
13+
it( 'should return animation keyframes', () => {
14+
15+
const testNotification: any = new MockNotification( {} );
16+
const expectedKeyframes: NotifierAnimationPresetKeyframes = {
17+
from: {
18+
opacity: '0'
19+
},
20+
to: {
21+
opacity: '1'
22+
}
23+
};
24+
const keyframes: NotifierAnimationPresetKeyframes = fade.show( testNotification );
25+
26+
expect( keyframes ).toEqual( expectedKeyframes );
27+
28+
} );
29+
30+
} );
31+
32+
describe( '(hide)', () => {
33+
34+
it( 'should return animation keyframes', () => {
35+
36+
const testNotification: any = new MockNotification( {} );
37+
const expectedKeyframes: NotifierAnimationPresetKeyframes = {
38+
from: {
39+
opacity: '1'
40+
},
41+
to: {
42+
opacity: '0'
43+
}
44+
};
45+
const keyframes: NotifierAnimationPresetKeyframes = fade.hide( testNotification );
46+
47+
expect( keyframes ).toEqual( expectedKeyframes );
48+
49+
} );
50+
51+
} );
52+
53+
} );
54+
55+
}
56+
57+
/**
58+
* Mock notification, providing static values except the global configuration
59+
*/
60+
class MockNotification {
61+
62+
/**
63+
* Configuration
64+
*/
65+
public config: any;
66+
67+
/**
68+
* Notification ID
69+
*/
70+
public id: string = 'ID_FAKE';
71+
72+
/**
73+
* Notification type
74+
*/
75+
public type: string = 'SUCCESS';
76+
77+
/**
78+
* Notification message
79+
*/
80+
public message: string = 'Lorem ipsum dolor sit amet.';
81+
82+
/**
83+
* Notification component
84+
*/
85+
public component: any = {
86+
getConfig: () => this.config,
87+
getHeight: () => 40,
88+
getShift: () => 80,
89+
getWidth: () => 300
90+
};
91+
92+
/**
93+
* Constructor
94+
*
95+
* @param {any} config Configuration
96+
*/
97+
public constructor( config: any ) {
98+
this.config = config;
99+
}
100+
101+
}

0 commit comments

Comments
 (0)