blob: f286a8ec1b6a2e9f34cdab4c22db4c41a1b574fc [file] [log] [blame]
Matteo Scandoloc49f53c2016-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 Scandolob3b03172016-05-16 09:59:38 -07008// NODE Actually the code is working, the tests are not.
Matteo Scandoloc49f53c2016-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 Scandoloc49f53c2016-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 Scandolob3b03172016-05-16 09:59:38 -070025 // console.log('$injector',$injector.get('logDecorator'));
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070026 $provide.value('$log', mockLog);
Matteo Scandolob3b03172016-05-16 09:59:38 -070027 // $provide.decorator('$log', $injector.get('logDecorator'));
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070028 });
29 });
30
Matteo Scandolob3b03172016-05-16 09:59:38 -070031 beforeEach(inject(($log) => {
32 log = $log;
33 // log.reset();
34 }));
Matteo Scandoloc49f53c2016-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 Scandolob3b03172016-05-16 09:59:38 -070040 expect(mockLog.info).not.toHaveBeenCalled();
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070041 }));
42
Matteo Scandolob3b03172016-05-16 09:59:38 -070043 });
44 describe('if logging is enabled', () => {
45 beforeEach(() => {
46 window.location.href += '?debug=true'
47 });
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070048
Matteo Scandolob3b03172016-05-16 09:59:38 -070049 it('should should log', () => {
50 log.info('test');
51 console.log(log.info.logs);
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070052 });
53 });
54 });
55})();