]>
git.proxmox.com Git - mirror_novnc.git/blob - tests/test.util.js
1 var assert
= chai
.assert
;
2 var expect
= chai
.expect
;
4 import * as Log
from '../core/util/logging.js';
6 import sinon
from '../vendor/sinon.js';
8 describe('Utils', function() {
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');
20 afterEach(function () {
21 console
.log
.restore();
22 console
.debug
.restore();
23 console
.warn
.restore();
24 console
.error
.restore();
25 console
.info
.restore();
29 it('should use noop for levels lower than the min level', function () {
30 Log
.init_logging('warn');
33 expect(console
.log
).to
.not
.have
.been
.called
;
36 it('should use console.debug for Debug', function () {
37 Log
.init_logging('debug');
39 expect(console
.debug
).to
.have
.been
.calledWith('dbg');
42 it('should use console.info for Info', function () {
43 Log
.init_logging('debug');
45 expect(console
.info
).to
.have
.been
.calledWith('inf');
48 it('should use console.warn for Warn', function () {
49 Log
.init_logging('warn');
51 expect(console
.warn
).to
.have
.been
.called
;
52 expect(console
.warn
).to
.have
.been
.calledWith('wrn');
55 it('should use console.error for Error', function () {
56 Log
.init_logging('error');
58 expect(console
.error
).to
.have
.been
.called
;
59 expect(console
.error
).to
.have
.been
.calledWith('err');
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)