mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-08-16 14:40:23 +03:00
test: add test for conditionally loaded .node files
This commit is contained in:
parent
ad2aaa8c3c
commit
0f04fb2a74
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,5 +16,6 @@ node_modules
|
||||
docs/output
|
||||
docs/includes
|
||||
spec/fixtures/evil-files/
|
||||
!spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/node_modules/
|
||||
out/
|
||||
/electron/
|
||||
|
6
spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/main.js
vendored
Normal file
6
spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/main.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
const condition = false;
|
||||
|
||||
if (condition) {
|
||||
const { native } = require("./node_modules/native-module");
|
||||
native(condition);
|
||||
}
|
7
spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/node_modules/native-module/main.js
generated
vendored
Normal file
7
spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/node_modules/native-module/main.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
exports.native = function loadNative(condition) {
|
||||
if (condition) {
|
||||
return require('../build/Release/native.node');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
4
spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/node_modules/native-module/package.json
generated
vendored
Normal file
4
spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/node_modules/native-module/package.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "native-module",
|
||||
"main": "./main.js"
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "package-with-incompatible-native-module",
|
||||
"version": "1.0.0",
|
||||
"main": "./main.js"
|
||||
}
|
@ -45,6 +45,20 @@ describe('Package', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('detects the package as incompatible even if .node file is loaded conditionally', function() {
|
||||
const packagePath = atom.project
|
||||
.getDirectories()[0]
|
||||
.resolve(
|
||||
'packages/package-with-incompatible-native-module-loaded-conditionally'
|
||||
);
|
||||
const pack = buildPackage(packagePath);
|
||||
expect(pack.isCompatible()).toBe(false);
|
||||
expect(pack.incompatibleModules[0].name).toBe('native-module');
|
||||
expect(pack.incompatibleModules[0].path).toBe(
|
||||
path.join(packagePath, 'node_modules', 'native-module')
|
||||
);
|
||||
});
|
||||
|
||||
it("utilizes _atomModuleCache if present to determine the package's native dependencies", function() {
|
||||
let packagePath = atom.project
|
||||
.getDirectories()[0]
|
||||
|
Loading…
Reference in New Issue
Block a user