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