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