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