|
| 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