Matteo Scandolo | 686547a | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
Matteo Scandolo | a5d03d5 | 2016-07-21 11:35:46 -0700 | [diff] [blame] | 19 | /** |
| 20 | * © OpenCORD |
| 21 | * |
| 22 | * Created by teone on 4/18/16. |
| 23 | */ |
| 24 | /* eslint-disable angular/ng_window_service*/ |
| 25 | |
| 26 | // TODO write tests for log |
| 27 | // NODE Actually the code is working, the tests are not. |
| 28 | |
| 29 | (function () { |
| 30 | 'use strict'; |
| 31 | |
| 32 | xdescribe('The xos.helper module', function(){ |
| 33 | |
| 34 | let log, window; |
| 35 | |
| 36 | let mockLog; |
| 37 | |
| 38 | beforeEach(function() { |
| 39 | mockLog = jasmine.createSpyObj('logMock', ['info']); |
| 40 | }); |
| 41 | |
| 42 | beforeEach(function() { |
| 43 | angular.mock.module('xos.helpers', function($injector, $provide) { |
| 44 | // console.log('$injector',$injector.get('logDecorator')); |
| 45 | $provide.value('$log', mockLog); |
| 46 | // $provide.decorator('$log', $injector.get('logDecorator')); |
| 47 | }); |
| 48 | }); |
| 49 | |
| 50 | beforeEach(inject(($log, $window) => { |
| 51 | log = $log; |
| 52 | window = $window; |
| 53 | // log.reset(); |
| 54 | })); |
| 55 | |
| 56 | describe('The log decorator', () => { |
| 57 | it('should not print anything', inject(($log) => { |
| 58 | // spyOn(log, 'info'); |
| 59 | $log.info('test'); |
| 60 | expect(mockLog.info).not.toHaveBeenCalled(); |
| 61 | })); |
| 62 | |
| 63 | }); |
| 64 | describe('if logging is enabled', () => { |
| 65 | beforeEach(() => { |
| 66 | window.location.href += '?debug=true' |
| 67 | }); |
| 68 | |
| 69 | it('should should log', () => { |
| 70 | log.info('test'); |
| 71 | console.log(log.info.logs); |
| 72 | }); |
| 73 | }); |
| 74 | }); |
| 75 | })(); |