summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/utils/log/log.service.spec.ts
blob: 15a840f765c71f1206a2e1e7f796d8cf9d3d71bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {LogService} from "./log.service";
import {TestBed} from "@angular/core/testing";

describe('log service service', () => {

  let logService : LogService;

  beforeAll(done => (async () => {
    TestBed.configureTestingModule({

    });
    await TestBed.compileComponents();
    logService = new LogService();


  })().then(done).catch(done.fail));


  test('check all ILogger function are defined', ()=>{
    expect(logService.log).toBeDefined();
    expect(logService.assert).toBeDefined();
    expect(logService.error).toBeDefined();
    expect(logService.group).toBeDefined();
    expect(logService.groupEnd).toBeDefined();
    expect(logService.info).toBeDefined();
    expect(logService.warn).toBeDefined();
  });

  test('test getPrefixLog function: with data', ()=> {
    let args = ['message', [1,2,3,4,5]];
    let result  = LogService.getPrefixLog(args);
    expect(result).toBeDefined();
  });

  test('log assert', ()=> {
    jest.spyOn(console, 'assert');
    logService.assert('someArg');
    expect(console.assert).toHaveBeenCalled();
  });

  test('log group', ()=> {
    jest.spyOn(console, 'group');
    logService.group('someArg');
    expect(console.group).toHaveBeenCalled();
  });

  test('log groupEnd', ()=> {
    jest.spyOn(console, 'groupEnd');
    logService.groupEnd('someArg');
    expect(console.groupEnd).toHaveBeenCalled();
  });

  test('log log', ()=> {
    jest.spyOn(console, 'log');
    logService.log('someArg');
    expect(console.log).toHaveBeenCalled();
  });

  test('log warn', ()=> {
    spyOn(console, 'warn');
    logService.warn('someArg');
    expect(console.warn).toHaveBeenCalled();
  });

});