Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | |
| 2 | |
| 3 | import {LogService} from "./log.service"; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 4 | import {TestBed} from "@angular/core/testing"; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 5 | |
| 6 | describe('log service service', () => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 7 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 8 | let logService : LogService; |
| 9 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 10 | beforeAll(done => (async () => { |
| 11 | TestBed.configureTestingModule({ |
| 12 | |
| 13 | }); |
| 14 | await TestBed.compileComponents(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 15 | logService = new LogService(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 16 | |
| 17 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 18 | })().then(done).catch(done.fail)); |
| 19 | |
| 20 | |
| 21 | test('check all ILogger function are defined', ()=>{ |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 22 | expect(logService.log).toBeDefined(); |
| 23 | expect(logService.assert).toBeDefined(); |
| 24 | expect(logService.error).toBeDefined(); |
| 25 | expect(logService.group).toBeDefined(); |
| 26 | expect(logService.groupEnd).toBeDefined(); |
| 27 | expect(logService.info).toBeDefined(); |
| 28 | expect(logService.warn).toBeDefined(); |
| 29 | }); |
| 30 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 31 | test('test getPrefixLog function: with data', ()=> { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 32 | let args = ['message', [1,2,3,4,5]]; |
| 33 | let result = LogService.getPrefixLog(args); |
| 34 | expect(result).toBeDefined(); |
| 35 | }); |
| 36 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 37 | test('log assert', ()=> { |
| 38 | jest.spyOn(console, 'assert'); |
| 39 | logService.assert('someArg'); |
| 40 | expect(console.assert).toHaveBeenCalled(); |
| 41 | }); |
| 42 | |
| 43 | test('log group', ()=> { |
| 44 | jest.spyOn(console, 'group'); |
| 45 | logService.group('someArg'); |
| 46 | expect(console.group).toHaveBeenCalled(); |
| 47 | }); |
| 48 | |
| 49 | test('log groupEnd', ()=> { |
| 50 | jest.spyOn(console, 'groupEnd'); |
| 51 | logService.groupEnd('someArg'); |
| 52 | expect(console.groupEnd).toHaveBeenCalled(); |
| 53 | }); |
| 54 | |
| 55 | test('log log', ()=> { |
| 56 | jest.spyOn(console, 'log'); |
| 57 | logService.log('someArg'); |
| 58 | expect(console.log).toHaveBeenCalled(); |
| 59 | }); |
| 60 | |
| 61 | test('log warn', ()=> { |
| 62 | spyOn(console, 'warn'); |
| 63 | logService.warn('someArg'); |
| 64 | expect(console.warn).toHaveBeenCalled(); |
| 65 | }); |
| 66 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 67 | }); |