Skip to content

Commit

Permalink
Setup chai extensions centrally
Browse files Browse the repository at this point in the history
They have global effects so make that clear by doing the setup in a
single place.
  • Loading branch information
samhed committed Sep 28, 2017
1 parent 0aaf59c commit 13d9108
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
6 changes: 5 additions & 1 deletion tests/assertions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// some useful assertions for noVNC
// Assertions that make it easier to use sinon
import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js';
chai.use(sinonChai);

// noVNC specific assertions
chai.use(function (_chai, utils) {
_chai.Assertion.addMethod('displayed', function (target_data) {
var obj = this._obj;
Expand Down
3 changes: 2 additions & 1 deletion tests/karma-test-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var TEST_REGEXP = /test\..*\.js/;
var allTestFiles = [];
var extraFiles = ['/base/tests/assertions.js'];

Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
Expand All @@ -10,6 +11,6 @@ Object.keys(window.__karma__.files).forEach(function (file) {

require.config({
baseUrl: '/base',
deps: allTestFiles,
deps: allTestFiles.concat(extraFiles),
callback: window.__karma__.start,
});
3 changes: 0 additions & 3 deletions tests/test.display.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import Base64 from '../core/base64.js';
import Display from '../core/display.js';
import { _forceCursorURIs, browserSupportsCursorURIs } from '../core/util/browsers.js';

import './assertions.js';
import sinon from '../vendor/sinon.js';
import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js';
chai.use(sinonChai);

describe('Display/Canvas Helper', function () {
var checked_data = [
Expand Down
3 changes: 0 additions & 3 deletions tests/test.rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import RFB from '../core/rfb.js';
import Websock from '../core/websock.js';

import FakeWebSocket from './fake.websocket.js';
import './assertions';
import sinon from '../vendor/sinon.js';
import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js';
chai.use(sinonChai);

function make_rfb (extra_opts) {
if (!extra_opts) {
Expand Down
2 changes: 0 additions & 2 deletions tests/test.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import * as Log from '../core/util/logging.js';
import l10nGet, { l10n } from '../core/util/localization.js';

import sinon from '../vendor/sinon.js';
import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js';
chai.use(sinonChai);

describe('Utils', function() {
"use strict";
Expand Down
3 changes: 0 additions & 3 deletions tests/test.websock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ var expect = chai.expect;
import Websock from '../core/websock.js';
import FakeWebSocket from './fake.websocket.js';

import './assertions';
import sinon from '../vendor/sinon.js';
import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js';
chai.use(sinonChai);

describe('Websock', function() {
"use strict";
Expand Down

0 comments on commit 13d9108

Please sign in to comment.