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