Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 1 | /** |
| 2 | * © OpenCORD |
| 3 | * |
| 4 | * Created by teone on 4/18/16. |
| 5 | */ |
Matteo Scandolo | b2a1a18 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 6 | /* eslint-disable angular/ng_window_service*/ |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 7 | |
| 8 | // TODO write tests for log |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 9 | // NODE Actually the code is working, the tests are not. |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 10 | |
| 11 | (function () { |
| 12 | 'use strict'; |
| 13 | |
| 14 | xdescribe('The xos.helper module', function(){ |
| 15 | |
Matteo Scandolo | b2a1a18 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 16 | let log, window; |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 17 | |
Matteo Scandolo | b2a1a18 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 18 | let mockLog; |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 19 | |
| 20 | beforeEach(function() { |
| 21 | mockLog = jasmine.createSpyObj('logMock', ['info']); |
| 22 | }); |
| 23 | |
| 24 | beforeEach(function() { |
| 25 | angular.mock.module('xos.helpers', function($injector, $provide) { |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 26 | // console.log('$injector',$injector.get('logDecorator')); |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 27 | $provide.value('$log', mockLog); |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 28 | // $provide.decorator('$log', $injector.get('logDecorator')); |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 29 | }); |
| 30 | }); |
| 31 | |
Matteo Scandolo | b2a1a18 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 32 | beforeEach(inject(($log, $window) => { |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 33 | log = $log; |
Matteo Scandolo | b2a1a18 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 34 | window = $window; |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 35 | // log.reset(); |
| 36 | })); |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 37 | |
| 38 | describe('The log decorator', () => { |
| 39 | it('should not print anything', inject(($log) => { |
| 40 | // spyOn(log, 'info'); |
| 41 | $log.info('test'); |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 42 | expect(mockLog.info).not.toHaveBeenCalled(); |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 43 | })); |
| 44 | |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 45 | }); |
| 46 | describe('if logging is enabled', () => { |
| 47 | beforeEach(() => { |
| 48 | window.location.href += '?debug=true' |
| 49 | }); |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 50 | |
Matteo Scandolo | b3b0317 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 51 | it('should should log', () => { |
| 52 | log.info('test'); |
| 53 | console.log(log.info.logs); |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 54 | }); |
| 55 | }); |
| 56 | }); |
| 57 | })(); |