]> git.proxmox.com Git - mirror_novnc.git/blame - tests/test.util.js
Simpler reporting when display output size mismatches
[mirror_novnc.git] / tests / test.util.js
CommitLineData
d21cd6c1
SR
1/* jshint expr: true */
2
3var assert = chai.assert;
4var expect = chai.expect;
5
dfae3209 6import * as Log from '../core/util/logging.js';
dfae3209 7
0aaf59c2 8import sinon from '../vendor/sinon.js';
dfae3209 9
d21cd6c1
SR
10describe('Utils', function() {
11 "use strict";
12
d21cd6c1
SR
13 describe('logging functions', function () {
14 beforeEach(function () {
15 sinon.spy(console, 'log');
0ae5b50a 16 sinon.spy(console, 'debug');
d21cd6c1
SR
17 sinon.spy(console, 'warn');
18 sinon.spy(console, 'error');
e4fef7be 19 sinon.spy(console, 'info');
d21cd6c1
SR
20 });
21
22 afterEach(function () {
0242c032
SM
23 console.log.restore();
24 console.debug.restore();
25 console.warn.restore();
26 console.error.restore();
27 console.info.restore();
28 Log.init_logging();
d21cd6c1
SR
29 });
30
31 it('should use noop for levels lower than the min level', function () {
dfae3209
SR
32 Log.init_logging('warn');
33 Log.Debug('hi');
34 Log.Info('hello');
d21cd6c1
SR
35 expect(console.log).to.not.have.been.called;
36 });
37
0ae5b50a 38 it('should use console.debug for Debug', function () {
dfae3209
SR
39 Log.init_logging('debug');
40 Log.Debug('dbg');
0ae5b50a 41 expect(console.debug).to.have.been.calledWith('dbg');
e4fef7be 42 });
c464f47e 43
e4fef7be 44 it('should use console.info for Info', function () {
dfae3209
SR
45 Log.init_logging('debug');
46 Log.Info('inf');
e4fef7be 47 expect(console.info).to.have.been.calledWith('inf');
d21cd6c1
SR
48 });
49
50 it('should use console.warn for Warn', function () {
dfae3209
SR
51 Log.init_logging('warn');
52 Log.Warn('wrn');
d21cd6c1
SR
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 () {
dfae3209
SR
58 Log.init_logging('error');
59 Log.Error('err');
d21cd6c1
SR
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
ee7d4c61 69 // TODO(directxman12): figure out how to test the browser detection functions properly
d21cd6c1
SR
70 // (we can't really test them against the browsers, except for Gecko
71 // via PhantomJS, the default test driver)
d21cd6c1 72});