]>
git.proxmox.com Git - mirror_novnc.git/blob - tests/test.util.js
1 // requires local modules: util
2 /* jshint expr: true */
4 var assert
= chai
.assert
;
5 var expect
= chai
.expect
;
7 describe('Utils', function() {
10 describe('logging functions', function () {
11 beforeEach(function () {
12 sinon
.spy(console
, 'log');
13 sinon
.spy(console
, 'warn');
14 sinon
.spy(console
, 'error');
17 afterEach(function () {
18 console
.log
.restore();
19 console
.warn
.restore();
20 console
.error
.restore();
23 it('should use noop for levels lower than the min level', function () {
24 Util
.init_logging('warn');
27 expect(console
.log
).to
.not
.have
.been
.called
;
30 it('should use console.log for Debug and Info', function () {
31 Util
.init_logging('debug');
34 expect(console
.log
).to
.have
.been
.calledWith('dbg');
35 expect(console
.log
).to
.have
.been
.calledWith('inf');
38 it('should use console.warn for Warn', function () {
39 Util
.init_logging('warn');
41 expect(console
.warn
).to
.have
.been
.called
;
42 expect(console
.warn
).to
.have
.been
.calledWith('wrn');
45 it('should use console.error for Error', function () {
46 Util
.init_logging('error');
48 expect(console
.error
).to
.have
.been
.called
;
49 expect(console
.error
).to
.have
.been
.calledWith('err');
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)