mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 20:37:48 +00:00
Add _.noConflict test.
This commit is contained in:
20
test/test.js
20
test/test.js
@@ -11446,13 +11446,31 @@
|
|||||||
test('should return the `lodash` function', 1, function() {
|
test('should return the `lodash` function', 1, function() {
|
||||||
if (!isModularize) {
|
if (!isModularize) {
|
||||||
var oldDash = root._;
|
var oldDash = root._;
|
||||||
strictEqual(_.noConflict(), _);
|
strictEqual(_.noConflict(), oldDash);
|
||||||
root._ = oldDash;
|
root._ = oldDash;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
skipTest();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should work with a `context` of `this`', 2, function() {
|
||||||
|
if (!isModularize && !document && _._object) {
|
||||||
|
var fs = require('fs'),
|
||||||
|
vm = require('vm'),
|
||||||
|
expected = {},
|
||||||
|
context = vm.createContext({ '_': expected }),
|
||||||
|
source = fs.readFileSync(filePath);
|
||||||
|
|
||||||
|
vm.runInContext(source + '\nthis.lodash = this._.noConflict()', context);
|
||||||
|
|
||||||
|
strictEqual(context._, expected);
|
||||||
|
ok(!!context.lodash);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(2);
|
||||||
|
}
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user