blob: 15a840f765c71f1206a2e1e7f796d8cf9d3d71bd [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001
2
3import {LogService} from "./log.service";
Ittay Stern6f900cc2018-08-29 17:01:32 +03004import {TestBed} from "@angular/core/testing";
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03005
6describe('log service service', () => {
Ittay Stern6f900cc2018-08-29 17:01:32 +03007
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03008 let logService : LogService;
9
Ittay Stern6f900cc2018-08-29 17:01:32 +030010 beforeAll(done => (async () => {
11 TestBed.configureTestingModule({
12
13 });
14 await TestBed.compileComponents();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030015 logService = new LogService();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030016
17
Ittay Stern6f900cc2018-08-29 17:01:32 +030018 })().then(done).catch(done.fail));
19
20
21 test('check all ILogger function are defined', ()=>{
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030022 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 Stern6f900cc2018-08-29 17:01:32 +030031 test('test getPrefixLog function: with data', ()=> {
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030032 let args = ['message', [1,2,3,4,5]];
33 let result = LogService.getPrefixLog(args);
34 expect(result).toBeDefined();
35 });
36
Ittay Stern6f900cc2018-08-29 17:01:32 +030037 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)ff76b5e2018-07-10 15:57:37 +030067});