]>
git.proxmox.com Git - mirror_novnc.git/blob - tests/test.util.js
201acc8bb0d25c5e652ce2fbe777984d2d038c97
1 /* eslint-disable no-console */
2 const expect
= chai
.expect
;
4 import * as Log
from '../core/util/logging.js';
6 describe('Utils', function () {
9 describe('logging functions', function () {
10 beforeEach(function () {
11 sinon
.spy(console
, 'log');
12 sinon
.spy(console
, 'debug');
13 sinon
.spy(console
, 'warn');
14 sinon
.spy(console
, 'error');
15 sinon
.spy(console
, 'info');
18 afterEach(function () {
19 console
.log
.restore();
20 console
.debug
.restore();
21 console
.warn
.restore();
22 console
.error
.restore();
23 console
.info
.restore();
27 it('should use noop for levels lower than the min level', function () {
28 Log
.init_logging('warn');
31 expect(console
.log
).to
.not
.have
.been
.called
;
34 it('should use console.debug for Debug', function () {
35 Log
.init_logging('debug');
37 expect(console
.debug
).to
.have
.been
.calledWith('dbg');
40 it('should use console.info for Info', function () {
41 Log
.init_logging('debug');
43 expect(console
.info
).to
.have
.been
.calledWith('inf');
46 it('should use console.warn for Warn', function () {
47 Log
.init_logging('warn');
49 expect(console
.warn
).to
.have
.been
.called
;
50 expect(console
.warn
).to
.have
.been
.calledWith('wrn');
53 it('should use console.error for Error', function () {
54 Log
.init_logging('error');
56 expect(console
.error
).to
.have
.been
.called
;
57 expect(console
.error
).to
.have
.been
.calledWith('err');
61 // TODO(directxman12): test the conf_default and conf_defaults methods
62 // TODO(directxman12): test decodeUTF8
63 // TODO(directxman12): test the event methods (addEvent, removeEvent, stopEvent)
64 // TODO(directxman12): figure out a good way to test getPosition and getEventPosition
65 // TODO(directxman12): figure out how to test the browser detection functions properly
66 // (we can't really test them against the browsers, except for Gecko
67 // via PhantomJS, the default test driver)
69 /* eslint-enable no-console */