UEA-PRODEM
This commit is contained in:
+23
-3
@@ -140,7 +140,7 @@ test('symlinked', function (t) {
|
||||
});
|
||||
|
||||
test('readPackageSync', function (t) {
|
||||
t.plan(3);
|
||||
t.plan(4);
|
||||
|
||||
var files = {};
|
||||
files[path.resolve('/foo/node_modules/bar/something-else.js')] = 'beep';
|
||||
@@ -179,12 +179,12 @@ test('readPackageSync', function (t) {
|
||||
);
|
||||
});
|
||||
|
||||
var readPackageSync = function (readFileSync, file) {
|
||||
function readPackageSync(readFileSync, file) {
|
||||
if (file.indexOf(path.join('bar', 'package.json')) >= 0) {
|
||||
return { main: './something-else.js' };
|
||||
}
|
||||
return JSON.parse(files[path.resolve(file)]);
|
||||
};
|
||||
}
|
||||
|
||||
t.test('with readPackage', function (st) {
|
||||
st.plan(1);
|
||||
@@ -210,5 +210,25 @@ test('readPackageSync', function (t) {
|
||||
'errors when both readFile and readPackage are provided'
|
||||
);
|
||||
});
|
||||
|
||||
t.test('readPackageSync error propagates correctly', function (st) {
|
||||
st.plan(1);
|
||||
|
||||
var readPackageError = new Error('read package error');
|
||||
|
||||
function failReadPackageSync() {
|
||||
throw readPackageError;
|
||||
}
|
||||
|
||||
var options = opts('/foo');
|
||||
delete options.readFileSync;
|
||||
options.readPackageSync = failReadPackageSync;
|
||||
|
||||
st.throws(
|
||||
function () { resolve.sync('bar', options); },
|
||||
readPackageError,
|
||||
'readPackageSync error is thrown'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user