Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add trailing commas in test/js-native-api #46385

Merged
merged 1 commit into from Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion test/.eslintrc.yaml
Expand Up @@ -76,7 +76,6 @@ overrides:
- files:
- es-module/*.js
- es-module/*.mjs
- js-native-api/*/*.js
- parallel/*.js
- parallel/*.mjs
- pummel/*.js
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_array/test.js
Expand Up @@ -23,14 +23,14 @@ assert.throws(
() => {
test_array.TestGetElement(array, array.length + 1);
},
/^Error: assertion \(\(\(uint32_t\)index < length\)\) failed: Index out of bounds!$/
/^Error: assertion \(\(\(uint32_t\)index < length\)\) failed: Index out of bounds!$/,
);

assert.throws(
() => {
test_array.TestGetElement(array, -2);
},
/^Error: assertion \(index >= 0\) failed: Invalid index\. Expects a positive integer\.$/
/^Error: assertion \(index >= 0\) failed: Invalid index\. Expects a positive integer\.$/,
);

array.forEach(function(element, index) {
Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/test_bigint/test.js
Expand Up @@ -48,5 +48,5 @@ assert.throws(() => CreateTooBigBigInt(), {
// Test that we correctly forward exceptions from the engine.
assert.throws(() => MakeBigIntWordsThrow(), {
name: 'RangeError',
message: 'Maximum BigInt size exceeded'
message: 'Maximum BigInt size exceeded',
});
2 changes: 1 addition & 1 deletion test/js-native-api/test_constructor/test.js
Expand Up @@ -58,5 +58,5 @@ assert.deepStrictEqual(TestConstructor.TestDefineClass(), {
cbIsNull: 'Invalid argument',
cbDataIsNull: 'napi_ok',
propertiesIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});
22 changes: 11 additions & 11 deletions test/js-native-api/test_conversions/test.js
Expand Up @@ -143,76 +143,76 @@ assert.deepStrictEqual(test.testNull.getValueBool(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A boolean was expected'
inputTypeCheck: 'A boolean was expected',
});

assert.deepStrictEqual(test.testNull.getValueInt32(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});

assert.deepStrictEqual(test.testNull.getValueUint32(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});

assert.deepStrictEqual(test.testNull.getValueInt64(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});


assert.deepStrictEqual(test.testNull.getValueDouble(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});

assert.deepStrictEqual(test.testNull.coerceToBool(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'napi_ok'
inputTypeCheck: 'napi_ok',
});

assert.deepStrictEqual(test.testNull.coerceToObject(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'napi_ok'
inputTypeCheck: 'napi_ok',
});

assert.deepStrictEqual(test.testNull.coerceToString(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'napi_ok'
inputTypeCheck: 'napi_ok',
});

assert.deepStrictEqual(test.testNull.getValueStringUtf8(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
wrongTypeIn: 'A string was expected',
bufAndOutLengthIsNull: 'Invalid argument'
bufAndOutLengthIsNull: 'Invalid argument',
});

assert.deepStrictEqual(test.testNull.getValueStringLatin1(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
wrongTypeIn: 'A string was expected',
bufAndOutLengthIsNull: 'Invalid argument'
bufAndOutLengthIsNull: 'Invalid argument',
});

assert.deepStrictEqual(test.testNull.getValueStringUtf16(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
wrongTypeIn: 'A string was expected',
bufAndOutLengthIsNull: 'Invalid argument'
bufAndOutLengthIsNull: 'Invalid argument',
});
10 changes: 5 additions & 5 deletions test/js-native-api/test_error/test.js
Expand Up @@ -70,35 +70,35 @@ assert.throws(() => {
(err) => {
assert.strictEqual(err, value);
return true;
}
},
));

assert.throws(
() => test_error.throwErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'Error [error]'
message: 'Error [error]',
});

assert.throws(
() => test_error.throwRangeErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'RangeError [range error]'
message: 'RangeError [range error]',
});

assert.throws(
() => test_error.throwTypeErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'TypeError [type error]'
message: 'TypeError [type error]',
});

assert.throws(
() => test_error.throwSyntaxErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'SyntaxError [syntax error]'
message: 'SyntaxError [syntax error]',
});

let error = test_error.createError();
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_exception/test.js
Expand Up @@ -31,7 +31,7 @@ const test_exception = (function() {
// Test that the native side passes the exception through
assert.throws(
() => { test_exception.allowException(throwTheError); },
(err) => err === theError
(err) => err === theError,
);

// Test that the exception thrown above was marked as pending
Expand Down Expand Up @@ -59,7 +59,7 @@ const test_exception = (function() {
// Test that the native side passes the exception through
assert.throws(
() => { test_exception.constructAllowException(throwTheError); },
(err) => err === theError
(err) => err === theError,
);

// Test that the exception thrown above was marked as pending
Expand Down
6 changes: 3 additions & 3 deletions test/js-native-api/test_function/test.js
Expand Up @@ -40,13 +40,13 @@ assert.deepStrictEqual(test_function.TestCreateFunctionParameters(), {
envIsNull: 'Invalid argument',
nameIsNull: 'napi_ok',
cbIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

assert.throws(
() => test_function.TestBadReturnExceptionPending(),
{
code: 'throwing exception',
name: 'Error'
}
name: 'Error',
},
);
6 changes: 3 additions & 3 deletions test/js-native-api/test_general/testEnvCleanup.js
Expand Up @@ -11,7 +11,7 @@ if (process.argv[2] === 'child') {
'simple wrap': 0,
'wrap, removeWrap': 1,
'first wrap': 2,
'second wrap': 3
'second wrap': 3,
};

// We attach the three objects we will test to `module.exports` to ensure they
Expand Down Expand Up @@ -39,7 +39,7 @@ if (process.argv[2] === 'child') {
const { spawnSync } = require('child_process');

const child = spawnSync(process.execPath, [__filename, 'child'], {
stdio: [ process.stdin, 'pipe', process.stderr ]
stdio: [ process.stdin, 'pipe', process.stderr ],
});

// Grab the child's output and construct an object whose keys are the rows of
Expand All @@ -49,7 +49,7 @@ if (process.argv[2] === 'child') {
child.stdout.toString().split(/\r\n|\r|\n/g).reduce((obj, item) =>
Object.assign(obj, item ? { [item]: true } : {}), {}), {
'finalize at env cleanup for simple wrap': true,
'finalize at env cleanup for second wrap': true
'finalize at env cleanup for second wrap': true,
});

// Ensure that the child exited successfully.
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_general/testInstanceOf.js
Expand Up @@ -61,15 +61,15 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
function compareToNative(theObject, theConstructor) {
assert.strictEqual(
addon.doInstanceOf(theObject, theConstructor),
(theObject instanceof theConstructor)
(theObject instanceof theConstructor),
);
}

function MyClass() {}
Object.defineProperty(MyClass, Symbol.hasInstance, {
value: function(candidate) {
return 'mark' in candidate;
}
},
});

function MySubClass() {}
Expand Down
22 changes: 11 additions & 11 deletions test/js-native-api/test_object/test.js
Expand Up @@ -12,8 +12,8 @@ const object = {
1, 94, 'str', 12.321, { test: 'obj in arr' },
],
newObject: {
test: 'obj in obj'
}
test: 'obj in obj',
},
};

assert.strictEqual(test_object.Get(object, 'hello'), 'world');
Expand Down Expand Up @@ -91,7 +91,7 @@ assert.strictEqual(newObject.test_string, 'test string');
const cube = {
x: 10,
y: 10,
z: 10
z: 10,
};

assert.deepStrictEqual(test_object.Inflate(cube), { x: 11, y: 11, z: 11 });
Expand All @@ -107,7 +107,7 @@ assert.strictEqual(newObject.test_string, 'test string');
const sym4 = Symbol('4');
const object2 = {
[sym1]: '@@iterator',
[sym2]: sym3
[sym2]: sym3,
};

assert(test_object.Has(object2, sym1));
Expand Down Expand Up @@ -236,7 +236,7 @@ assert.strictEqual(newObject.test_string, 'test string');
// and includes indices and converts them to strings.

const object = { __proto__: {
inherited: 1
inherited: 1,
} };

const fooSymbol = Symbol('foo');
Expand All @@ -247,19 +247,19 @@ assert.strictEqual(newObject.test_string, 'test string');
value: 4,
enumerable: false,
writable: true,
configurable: true
configurable: true,
});
Object.defineProperty(object, 'writable', {
value: 4,
enumerable: true,
writable: true,
configurable: false
configurable: false,
});
Object.defineProperty(object, 'configurable', {
value: 4,
enumerable: true,
writable: false,
configurable: true
configurable: true,
});
object[5] = 5;

Expand Down Expand Up @@ -308,7 +308,7 @@ assert.deepStrictEqual(test_object.TestSetProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument'
valueIsNull: 'Invalid argument',
});

// Verify that passing NULL to napi_has_property() results in the correct
Expand All @@ -317,7 +317,7 @@ assert.deepStrictEqual(test_object.TestHasProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

// Verify that passing NULL to napi_get_property() results in the correct
Expand All @@ -326,7 +326,7 @@ assert.deepStrictEqual(test_object.TestGetProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

{
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_object/test_null.js
Expand Up @@ -9,7 +9,7 @@ const expectedForProperty = {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument'
valueIsNull: 'Invalid argument',
};
assert.deepStrictEqual(testNull.setProperty(), expectedForProperty);
assert.deepStrictEqual(testNull.getProperty(), expectedForProperty);
Expand All @@ -28,7 +28,7 @@ assert.deepStrictEqual(testNull.hasNamedProperty(), expectedForProperty);
const expectedForElement = {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument'
valueIsNull: 'Invalid argument',
};
assert.deepStrictEqual(testNull.setElement(), expectedForElement);
assert.deepStrictEqual(testNull.getElement(), expectedForElement);
Expand Down