diff --git a/test/helpers/index.js b/test/helpers/index.js index e9df664ee3..6ca11e9252 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -6,7 +6,7 @@ const nconf = require('nconf'); const fs = require('fs'); const winston = require('winston'); -const utils = require('../../public/src/utils'); +const utils = require('../../src/utils'); const helpers = module.exports; diff --git a/test/utils.js b/test/utils.js index b76196c3eb..58d0ef2299 100644 --- a/test/utils.js +++ b/test/utils.js @@ -3,7 +3,6 @@ const assert = require('assert'); const { JSDOM } = require('jsdom'); -const utils = require('../public/src/utils'); const slugify = require('../src/slugify'); const db = require('./mocks/databasemock'); @@ -11,14 +10,16 @@ describe('Utility Methods', () => { // https://gist.github.com/robballou/9ee108758dc5e0e2d028 // create some jsdom magic to allow jQuery to work const dom = new JSDOM(''); - const { window } = dom; - global.window = window; + global.window = dom.window; + global.document = dom.window.document; global.jQuery = require('jquery'); global.$ = global.jQuery; const { $ } = global; require('jquery-deserialize'); require('jquery-serializeobject'); + const utils = require('../public/src/utils'); + it('should serialize/deserialize form data properly', () => { const formSerialize = $(`
@@ -283,20 +284,10 @@ describe('Utility Methods', () => { }); it('should return false if not touch device', (done) => { - global.document = global.document || {}; - global.document.documentElement = {}; assert(!utils.isTouchDevice()); done(); }); - it('should return true if touch device', (done) => { - global.document.documentElement = { - ontouchstart: 1, - }; - assert(utils.isTouchDevice()); - done(); - }); - it('should check if element is in viewport', (done) => { const el = $('
some text
'); assert(utils.isElementInViewport(el)); @@ -304,7 +295,6 @@ describe('Utility Methods', () => { }); it('should get empty object for url params', (done) => { - global.document = window.document; const params = utils.params(); assert.equal(Object.keys(params), 0); done();