blob: 21085c6b8a2ecabda37778142cfc633d2b1caf03 [file] [log] [blame]
Matteo Scandoloc49f53c2016-04-20 11:38:42 -07001/**
2 * © OpenCORD
3 *
4 * Created by teone on 4/18/16.
5 */
Matteo Scandolob2a1a182016-06-15 14:53:33 -07006/* eslint-disable angular/ng_window_service*/
Matteo Scandoloc49f53c2016-04-20 11:38:42 -07007
8// TODO write tests for log
Matteo Scandolob3b03172016-05-16 09:59:38 -07009// NODE Actually the code is working, the tests are not.
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070010
11(function () {
12 'use strict';
13
14 xdescribe('The xos.helper module', function(){
15
Matteo Scandolob2a1a182016-06-15 14:53:33 -070016 let log, window;
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070017
Matteo Scandolob2a1a182016-06-15 14:53:33 -070018 let mockLog;
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070019
20 beforeEach(function() {
21 mockLog = jasmine.createSpyObj('logMock', ['info']);
22 });
23
24 beforeEach(function() {
25 angular.mock.module('xos.helpers', function($injector, $provide) {
Matteo Scandolob3b03172016-05-16 09:59:38 -070026 // console.log('$injector',$injector.get('logDecorator'));
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070027 $provide.value('$log', mockLog);
Matteo Scandolob3b03172016-05-16 09:59:38 -070028 // $provide.decorator('$log', $injector.get('logDecorator'));
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070029 });
30 });
31
Matteo Scandolob2a1a182016-06-15 14:53:33 -070032 beforeEach(inject(($log, $window) => {
Matteo Scandolob3b03172016-05-16 09:59:38 -070033 log = $log;
Matteo Scandolob2a1a182016-06-15 14:53:33 -070034 window = $window;
Matteo Scandolob3b03172016-05-16 09:59:38 -070035 // log.reset();
36 }));
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070037
38 describe('The log decorator', () => {
39 it('should not print anything', inject(($log) => {
40 // spyOn(log, 'info');
41 $log.info('test');
Matteo Scandolob3b03172016-05-16 09:59:38 -070042 expect(mockLog.info).not.toHaveBeenCalled();
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070043 }));
44
Matteo Scandolob3b03172016-05-16 09:59:38 -070045 });
46 describe('if logging is enabled', () => {
47 beforeEach(() => {
48 window.location.href += '?debug=true'
49 });
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070050
Matteo Scandolob3b03172016-05-16 09:59:38 -070051 it('should should log', () => {
52 log.info('test');
53 console.log(log.info.logs);
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070054 });
55 });
56 });
57})();