test(util) scope: coverage

This commit is contained in:
coderaiser 2017-08-04 14:04:06 +03:00
parent abc051cad1
commit 8b7b3f27ed
2 changed files with 21 additions and 2 deletions

View file

@ -2,7 +2,8 @@
const test = require('tape');
const DIR = '../../';
const Util = require(DIR + 'common/util');
const UtilPath = DIR + 'common/util';
const Util = require(UtilPath);
const {
getStrBigFirst,
kebabToCamelCase,
@ -132,3 +133,20 @@ test('util: escapeRegExp', (t) => {
t.end();
});
test('util: scope', (t) => {
global.window = {};
clean(UtilPath);
require(UtilPath);
t.pass('should set window in scope');
delete global.window;
t.end();
});
function clean(path) {
delete require.cache[require.resolve(path)];
}