THRIFT-5811: Update eslint & prettier
Client: js
Patch: Cameron Martin
This closes #3087
diff --git a/lib/nodejs/test/test_driver.js b/lib/nodejs/test/test_driver.js
index 7c9a919..0593aea 100644
--- a/lib/nodejs/test/test_driver.js
+++ b/lib/nodejs/test/test_driver.js
@@ -34,18 +34,18 @@
const Int64 = require("node-int64");
const testCases = require("./test-cases");
-exports.ThriftTestDriver = function(client, callback) {
+exports.ThriftTestDriver = function (client, callback) {
test(
"NodeJS Style Callback Client Tests",
{ skip: helpers.ecmaMode === "es6" },
- function(assert) {
+ function (assert) {
const checkRecursively = makeRecursiveCheck(assert);
function makeAsserter(assertionFn) {
- return function(c) {
+ return function (c) {
const fnName = c[0];
const expected = c[1];
- client[fnName](expected, function(err, actual) {
+ client[fnName](expected, function (err, actual) {
assert.error(err, fnName + ": no callback error");
assertionFn(actual, expected, fnName);
});
@@ -53,18 +53,18 @@
}
testCases.simple.forEach(
- makeAsserter(function(a, e, m) {
+ makeAsserter(function (a, e, m) {
if (a instanceof Int64) {
const e64 = e instanceof Int64 ? e : new Int64(e);
assert.deepEqual(a.buffer, e64.buffer, m);
} else {
assert.equal(a, e, m);
}
- })
+ }),
);
testCases.deep.forEach(makeAsserter(assert.deepEqual));
testCases.deepUnordered.forEach(
- makeAsserter(makeUnorderedDeepEqual(assert))
+ makeAsserter(makeUnorderedDeepEqual(assert)),
);
const arr = [];
@@ -72,106 +72,106 @@
arr[i] = 255 - i;
}
let buf = new Buffer(arr);
- client.testBinary(buf, function(err, response) {
+ client.testBinary(buf, function (err, response) {
assert.error(err, "testBinary: no callback error");
assert.equal(response.length, 256, "testBinary");
assert.deepEqual(response, buf, "testBinary(Buffer)");
});
buf = new Buffer(arr);
- client.testBinary(buf.toString("binary"), function(err, response) {
+ client.testBinary(buf.toString("binary"), function (err, response) {
assert.error(err, "testBinary: no callback error");
assert.equal(response.length, 256, "testBinary");
assert.deepEqual(response, buf, "testBinary(string)");
});
- client.testMapMap(42, function(err, response) {
+ client.testMapMap(42, function (err, response) {
const expected = {
- "4": { "1": 1, "2": 2, "3": 3, "4": 4 },
- "-4": { "-4": -4, "-3": -3, "-2": -2, "-1": -1 }
+ 4: { 1: 1, 2: 2, 3: 3, 4: 4 },
+ "-4": { "-4": -4, "-3": -3, "-2": -2, "-1": -1 },
};
assert.error(err, "testMapMap: no callback error");
assert.deepEqual(expected, response, "testMapMap");
});
- client.testStruct(testCases.out, function(err, response) {
+ client.testStruct(testCases.out, function (err, response) {
assert.error(err, "testStruct: no callback error");
checkRecursively(testCases.out, response, "testStruct");
});
- client.testNest(testCases.out2, function(err, response) {
+ client.testNest(testCases.out2, function (err, response) {
assert.error(err, "testNest: no callback error");
checkRecursively(testCases.out2, response, "testNest");
});
- client.testInsanity(testCases.crazy, function(err, response) {
+ client.testInsanity(testCases.crazy, function (err, response) {
assert.error(err, "testInsanity: no callback error");
checkRecursively(testCases.insanity, response, "testInsanity");
});
- client.testInsanity(testCases.crazy2, function(err, response) {
+ client.testInsanity(testCases.crazy2, function (err, response) {
assert.error(err, "testInsanity2: no callback error");
checkRecursively(testCases.insanity, response, "testInsanity2");
});
- client.testException("TException", function(err, response) {
+ client.testException("TException", function (err, response) {
assert.ok(
err instanceof TException,
- "testException: correct error type"
+ "testException: correct error type",
);
assert.ok(!response, "testException: no response");
});
- client.testException("Xception", function(err, response) {
+ client.testException("Xception", function (err, response) {
assert.ok(
err instanceof ttypes.Xception,
- "testException: correct error type"
+ "testException: correct error type",
);
assert.ok(!response, "testException: no response");
assert.equal(err.errorCode, 1001, "testException: correct error code");
assert.equal(
"Xception",
err.message,
- "testException: correct error message"
+ "testException: correct error message",
);
});
- client.testException("no Exception", function(err, response) {
+ client.testException("no Exception", function (err, response) {
assert.error(err, "testException: no callback error");
assert.ok(!response, "testException: no response");
});
- client.testOneway(0, function(err, response) {
+ client.testOneway(0, function (err, response) {
assert.error(err, "testOneway: no callback error");
assert.strictEqual(response, undefined, "testOneway: void response");
});
- checkOffByOne(function(done) {
- client.testI32(-1, function(err, response) {
+ checkOffByOne(function (done) {
+ client.testI32(-1, function (err, response) {
assert.error(err, "checkOffByOne: no callback error");
assert.equal(-1, response);
assert.end();
done();
});
}, callback);
- }
+ },
);
// ES6 does not support callback style
if (helpers.ecmaMode === "es6") {
- checkOffByOne(done => done(), callback);
+ checkOffByOne((done) => done(), callback);
}
};
-exports.ThriftTestDriverPromise = function(client, callback) {
- test("Promise Client Tests", function(assert) {
+exports.ThriftTestDriverPromise = function (client, callback) {
+ test("Promise Client Tests", function (assert) {
const checkRecursively = makeRecursiveCheck(assert);
function makeAsserter(assertionFn) {
- return function(c) {
+ return function (c) {
const fnName = c[0];
const expected = c[1];
client[fnName](expected)
- .then(function(actual) {
+ .then(function (actual) {
assertionFn(actual, expected, fnName);
})
.catch(() => assert.fail("fnName"));
@@ -179,63 +179,63 @@
}
testCases.simple.forEach(
- makeAsserter(function(a, e, m) {
+ makeAsserter(function (a, e, m) {
if (a instanceof Int64) {
const e64 = e instanceof Int64 ? e : new Int64(e);
assert.deepEqual(a.buffer, e64.buffer, m);
} else {
assert.equal(a, e, m);
}
- })
+ }),
);
testCases.deep.forEach(makeAsserter(assert.deepEqual));
testCases.deepUnordered.forEach(
- makeAsserter(makeUnorderedDeepEqual(assert))
+ makeAsserter(makeUnorderedDeepEqual(assert)),
);
client
.testStruct(testCases.out)
- .then(function(response) {
+ .then(function (response) {
checkRecursively(testCases.out, response, "testStruct");
})
.catch(() => assert.fail("testStruct"));
client
.testNest(testCases.out2)
- .then(function(response) {
+ .then(function (response) {
checkRecursively(testCases.out2, response, "testNest");
})
.catch(() => assert.fail("testNest"));
client
.testInsanity(testCases.crazy)
- .then(function(response) {
+ .then(function (response) {
checkRecursively(testCases.insanity, response, "testInsanity");
})
.catch(() => assert.fail("testInsanity"));
client
.testInsanity(testCases.crazy2)
- .then(function(response) {
+ .then(function (response) {
checkRecursively(testCases.insanity, response, "testInsanity2");
})
.catch(() => assert.fail("testInsanity2"));
client
.testException("TException")
- .then(function() {
+ .then(function () {
assert.fail("testException: TException");
})
- .catch(function(err) {
+ .catch(function (err) {
assert.ok(err instanceof TException);
});
client
.testException("Xception")
- .then(function() {
+ .then(function () {
assert.fail("testException: Xception");
})
- .catch(function(err) {
+ .catch(function (err) {
assert.ok(err instanceof ttypes.Xception);
assert.equal(err.errorCode, 1001);
assert.equal("Xception", err.message);
@@ -243,22 +243,22 @@
client
.testException("no Exception")
- .then(function(response) {
+ .then(function (response) {
assert.equal(undefined, response); //void
})
.catch(() => assert.fail("testException"));
client
.testOneway(0)
- .then(function(response) {
+ .then(function (response) {
assert.strictEqual(response, undefined, "testOneway: void response");
})
.catch(() => assert.fail("testOneway: should not reject"));
- checkOffByOne(function(done) {
+ checkOffByOne(function (done) {
client
.testI32(-1)
- .then(function(response) {
+ .then(function (response) {
assert.equal(-1, response);
assert.end();
done();
@@ -272,7 +272,7 @@
// =========================================================
function makeRecursiveCheck(assert) {
- return function(map1, map2, msg) {
+ return function (map1, map2, msg) {
const equal = checkRecursively(map1, map2);
assert.ok(equal, msg);
@@ -295,7 +295,7 @@
return map1 == map2;
}
} else {
- return Object.keys(map1).every(function(key) {
+ return Object.keys(map1).every(function (key) {
return checkRecursively(map1[key], map2[key]);
});
}
@@ -319,7 +319,7 @@
* Because this is the last test against the server, when it completes
* the entire suite is complete by definition (the tests run serially).
*/
- done(function() {
+ done(function () {
test_complete = true;
});
@@ -334,7 +334,7 @@
callback(
"Server test failed to complete after " +
(retry_limit * retry_interval) / 1000 +
- " seconds"
+ " seconds",
);
}
}
@@ -344,7 +344,7 @@
}
function makeUnorderedDeepEqual(assert) {
- return function(actual, expected, name) {
+ return function (actual, expected, name) {
assert.equal(actual.length, expected.length, name);
for (const k in actual) {
let found = false;