mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00

Fix tests whether errors are thrown correctly because they are successful when error doesn't get thrown. PR-URL: https://github.com/nodejs/node/pull/27333 Fixes: https://github.com/nodejs/node/issues/26385 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
23 lines
772 B
JavaScript
23 lines
772 B
JavaScript
'use strict';
|
||
|
||
const common = require('../../common');
|
||
const assert = require('assert');
|
||
const {
|
||
makeBufferInNewContext
|
||
} = require(`./build/${common.buildType}/binding`);
|
||
|
||
// Because the `Buffer` function and its protoype property only (currently)
|
||
// exist in a Node.js instance’s main context, trying to create buffers from
|
||
// another context throws an exception.
|
||
assert.throws(
|
||
() => makeBufferInNewContext(),
|
||
(exception) => {
|
||
assert.strictEqual(exception.constructor.name, 'Error');
|
||
assert(!(exception.constructor instanceof Error));
|
||
|
||
assert.strictEqual(exception.code, 'ERR_BUFFER_CONTEXT_NOT_AVAILABLE');
|
||
assert.strictEqual(exception.message,
|
||
'Buffer is not available for the current Context');
|
||
return true;
|
||
}
|
||
);
|