mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(util) scope: coverage
This commit is contained in:
parent
abc051cad1
commit
8b7b3f27ed
2 changed files with 21 additions and 2 deletions
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
const exec = require('execon');
|
||||
const jonny = require('jonny');
|
||||
const Scope = global || window;
|
||||
|
||||
const Scope = typeof window !== 'undefined' ? window : global;
|
||||
|
||||
module.exports.getStrBigFirst = getStrBigFirst;
|
||||
module.exports.kebabToCamelCase = kebabToCamelCase;
|
||||
|
|
|
|||
|
|
@ -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)];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue