mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Remove obsolete done callbacks from the unit tests
The done callbacks are an outdated mechanism to signal Jasmine that a unit test is done, mostly in cases where a unit test needed to wait for an asynchronous operation to complete before doing its assertions. Nowadays a much better mechanism is in place for that, namely simply passing an asynchronous function to Jasmine, so we don't need callbacks anymore (which require more code and may be more difficult to reason about). In these particular cases though the done callbacks never had any real use since nothing asynchronous happens in these places. Synchronous functions don't need to use done callbacks since Jasmine simply knows it's done when the function reaches its normal end, so we can safely get rid of these callbacks. The telltale sign is if the done callback is used unconditionally at the end of the function. This is all done in an effort to over time get rid of all callbacks in the unit test code.
This commit is contained in:
parent
d9d626a5e1
commit
10574a0f8a
14 changed files with 38 additions and 80 deletions
|
@ -34,7 +34,7 @@ describe("Scripting", function () {
|
|||
});
|
||||
}
|
||||
|
||||
beforeAll(function (done) {
|
||||
beforeAll(function () {
|
||||
test_id = 0;
|
||||
ref = 1;
|
||||
send_queue = new Map();
|
||||
|
@ -70,7 +70,6 @@ describe("Scripting", function () {
|
|||
return promise.then(sbx => sbx.evalForTesting(code, key));
|
||||
},
|
||||
};
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
|
@ -204,13 +203,12 @@ describe("Scripting", function () {
|
|||
});
|
||||
|
||||
describe("Util", function () {
|
||||
beforeAll(function (done) {
|
||||
beforeAll(function () {
|
||||
sandbox.createSandbox({
|
||||
appInfo: { language: "en-US", platform: "Linux x86_64" },
|
||||
objects: {},
|
||||
calculationOrder: [],
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
describe("printd", function () {
|
||||
|
@ -486,13 +484,12 @@ describe("Scripting", function () {
|
|||
});
|
||||
|
||||
describe("Color", function () {
|
||||
beforeAll(function (done) {
|
||||
beforeAll(function () {
|
||||
sandbox.createSandbox({
|
||||
appInfo: { language: "en-US", platform: "Linux x86_64" },
|
||||
objects: {},
|
||||
calculationOrder: [],
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
function round(color) {
|
||||
|
@ -566,13 +563,12 @@ describe("Scripting", function () {
|
|||
});
|
||||
|
||||
describe("App", function () {
|
||||
beforeAll(function (done) {
|
||||
beforeAll(function () {
|
||||
sandbox.createSandbox({
|
||||
appInfo: { language: "en-US", platform: "Linux x86_64" },
|
||||
objects: {},
|
||||
calculationOrder: [],
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it("should test language", async () => {
|
||||
|
@ -593,14 +589,13 @@ describe("Scripting", function () {
|
|||
});
|
||||
|
||||
describe("AForm", function () {
|
||||
beforeAll(function (done) {
|
||||
beforeAll(function () {
|
||||
sandbox.createSandbox({
|
||||
appInfo: { language: "en-US", platform: "Linux x86_64" },
|
||||
objects: {},
|
||||
calculationOrder: [],
|
||||
dispatchEventName: "_dispatchMe",
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
describe("AFExtractNums", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue