]> git.proxmox.com Git - mirror_novnc.git/blob - tests/test.util.js
Move localization.js to app
[mirror_novnc.git] / tests / test.util.js
1 /* jshint expr: true */
2
3 var assert = chai.assert;
4 var expect = chai.expect;
5
6 import * as Log from '../core/util/logging.js';
7
8 import sinon from '../vendor/sinon.js';
9
10 describe('Utils', function() {
11 "use strict";
12
13 describe('logging functions', function () {
14 beforeEach(function () {
15 sinon.spy(console, 'log');
16 sinon.spy(console, 'debug');
17 sinon.spy(console, 'warn');
18 sinon.spy(console, 'error');
19 sinon.spy(console, 'info');
20 });
21
22 afterEach(function () {
23 console.log.restore();
24 console.debug.restore();
25 console.warn.restore();
26 console.error.restore();
27 console.info.restore();
28 Log.init_logging();
29 });
30
31 it('should use noop for levels lower than the min level', function () {
32 Log.init_logging('warn');
33 Log.Debug('hi');
34 Log.Info('hello');
35 expect(console.log).to.not.have.been.called;
36 });
37
38 it('should use console.debug for Debug', function () {
39 Log.init_logging('debug');
40 Log.Debug('dbg');
41 expect(console.debug).to.have.been.calledWith('dbg');
42 });
43
44 it('should use console.info for Info', function () {
45 Log.init_logging('debug');
46 Log.Info('inf');
47 expect(console.info).to.have.been.calledWith('inf');
48 });
49
50 it('should use console.warn for Warn', function () {
51 Log.init_logging('warn');
52 Log.Warn('wrn');
53 expect(console.warn).to.have.been.called;
54 expect(console.warn).to.have.been.calledWith('wrn');
55 });
56
57 it('should use console.error for Error', function () {
58 Log.init_logging('error');
59 Log.Error('err');
60 expect(console.error).to.have.been.called;
61 expect(console.error).to.have.been.calledWith('err');
62 });
63 });
64
65 // TODO(directxman12): test the conf_default and conf_defaults methods
66 // TODO(directxman12): test decodeUTF8
67 // TODO(directxman12): test the event methods (addEvent, removeEvent, stopEvent)
68 // TODO(directxman12): figure out a good way to test getPosition and getEventPosition
69 // TODO(directxman12): figure out how to test the browser detection functions properly
70 // (we can't really test them against the browsers, except for Gecko
71 // via PhantomJS, the default test driver)
72 });