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