]>
git.proxmox.com Git - mirror_novnc.git/blob - tests/test.util.js
1 /* jshint expr: true */
3 var assert
= chai
.assert
;
4 var expect
= chai
.expect
;
6 import * as Log
from '../core/util/logging.js';
8 import sinon
from '../vendor/sinon.js';
10 describe('Utils', function() {
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');
22 afterEach(function () {
23 console
.log
.restore();
24 console
.debug
.restore();
25 console
.warn
.restore();
26 console
.error
.restore();
27 console
.info
.restore();
31 it('should use noop for levels lower than the min level', function () {
32 Log
.init_logging('warn');
35 expect(console
.log
).to
.not
.have
.been
.called
;
38 it('should use console.debug for Debug', function () {
39 Log
.init_logging('debug');
41 expect(console
.debug
).to
.have
.been
.calledWith('dbg');
44 it('should use console.info for Info', function () {
45 Log
.init_logging('debug');
47 expect(console
.info
).to
.have
.been
.calledWith('inf');
50 it('should use console.warn for Warn', function () {
51 Log
.init_logging('warn');
53 expect(console
.warn
).to
.have
.been
.called
;
54 expect(console
.warn
).to
.have
.been
.calledWith('wrn');
57 it('should use console.error for Error', function () {
58 Log
.init_logging('error');
60 expect(console
.error
).to
.have
.been
.called
;
61 expect(console
.error
).to
.have
.been
.calledWith('err');
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)