blob: f286a8ec1b6a2e9f34cdab4c22db4c41a1b574fc [file] [log] [blame]
Matteo Scandolo7bc39c42016-04-20 11:38:42 -07001/**
2 * © OpenCORD
3 *
4 * Created by teone on 4/18/16.
5 */
6
7// TODO write tests for log
Matteo Scandolo280dcd32016-05-16 09:59:38 -07008// NODE Actually the code is working, the tests are not.
Matteo Scandolo7bc39c42016-04-20 11:38:42 -07009
10(function () {
11 'use strict';
12
13 xdescribe('The xos.helper module', function(){
14
15 let log;
16
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070017 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 Scandolo280dcd32016-05-16 09:59:38 -070025 // console.log('$injector',$injector.get('logDecorator'));
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070026 $provide.value('$log', mockLog);
Matteo Scandolo280dcd32016-05-16 09:59:38 -070027 // $provide.decorator('$log', $injector.get('logDecorator'));
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070028 });
29 });
30
Matteo Scandolo280dcd32016-05-16 09:59:38 -070031 beforeEach(inject(($log) => {
32 log = $log;
33 // log.reset();
34 }));
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070035
36 describe('The log decorator', () => {
37 it('should not print anything', inject(($log) => {
38 // spyOn(log, 'info');
39 $log.info('test');
Matteo Scandolo280dcd32016-05-16 09:59:38 -070040 expect(mockLog.info).not.toHaveBeenCalled();
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070041 }));
42
Matteo Scandolo280dcd32016-05-16 09:59:38 -070043 });
44 describe('if logging is enabled', () => {
45 beforeEach(() => {
46 window.location.href += '?debug=true'
47 });
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070048
Matteo Scandolo280dcd32016-05-16 09:59:38 -070049 it('should should log', () => {
50 log.info('test');
51 console.log(log.info.logs);
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070052 });
53 });
54 });
55})();