Skip to content

Commit

Permalink
Update jest
Browse files Browse the repository at this point in the history
  • Loading branch information
crayolakat committed Nov 14, 2022
1 parent db19bf5 commit 9ce5253
Show file tree
Hide file tree
Showing 27 changed files with 66 additions and 63 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"presets": ["@babel/preset-react", "@babel/preset-env", ["@babel/preset-typescript", { "allExtensions": true, "isTSX": true }]],
"only": ["./**/*.js", "./**/*.jsx"],
"plugins": [
"@babel/plugin-proposal-export-default-from",
["@babel/plugin-transform-runtime", {
"regenerator": true
}]
Expand Down
4 changes: 2 additions & 2 deletions __test__/backend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async function createCampaign(user, title, description, organizationId) {

// graphQL tests

describe("graphql test suite", async () => {
describe("graphql test suite", () => {
beforeAll(
async () => await setupTest(),
global.DATABASE_SETUP_TEARDOWN_TIMEOUT
Expand Down Expand Up @@ -352,7 +352,7 @@ describe("graphql test suite", async () => {
}).save();
});

describe("contacts", async () => {
describe("contacts", () => {
let campaigns;
let contacts;
beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function genComponent(assignment, propertyOverrides = {}) {
return wrapper;
}

describe("ContactController process flows", async () => {
describe("ContactController process flows", () => {
it("Normal nondynamic assignment queue", async () => {
const assignment = genAssignment(
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
createStartedCampaign
} from "../../test_helpers";

describe.skip("ConversationPreviewModal", async () => {
describe.skip("ConversationPreviewModal", () => {
let startedCampaign;
let optOutContact;
let optOut;
Expand Down Expand Up @@ -80,7 +80,7 @@ describe.skip("ConversationPreviewModal", async () => {
if (r.redis) r.redis.flushdb();
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT);

describe("when a message review user opts out a user", async () => {
describe("when a message review user opts out a user", () => {
beforeAll(async () => {
const root = document.createElement("div");
document.body.appendChild(root);
Expand Down
2 changes: 1 addition & 1 deletion __test__/components/ScriptEditor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Editor } from "draft-js";
import ScriptEditor from "../../src/components/ScriptEditor";
import { sleep } from "../test_helpers";

describe("ScriptEditor component", async () => {
describe("ScriptEditor component", () => {
test("re-encodes unicode easy-wins for GSM", () => {
const wrapper = shallow(
<ScriptEditor
Expand Down
2 changes: 1 addition & 1 deletion __test__/cypress/integration/basic-campaign-e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe("End-to-end campaign flow", () => {
});
cy.get("button[data-test=send]")
.eq(0)
.click();
.click({ waitForAnimations: false }); // Turn off animation wait to prevent false positive error

// Shows we're done and click back to /todos
cy.get("body").contains("You've messaged all your assigned contacts.");
Expand Down
2 changes: 1 addition & 1 deletion __test__/extensions/action-handlers/action-network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("action-network", () => {
};
});

describe("#getClientChoiceData", async () => {
describe("#getClientChoiceData", () => {
let makeGetEventsNock;
let makeGetTagsNock;
let getEventsNock;
Expand Down
2 changes: 1 addition & 1 deletion __test__/extensions/action-handlers/ngpvan-action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("ngpvn-action", () => {
).not.toThrowError();
});

describe("#getClientChoiceData", async () => {
describe("#getClientChoiceData", () => {
let makeGetSurveyQuestionsNock;
let makeGetActivistCodesNock;
let makeGetCanvassResponsesResultCodesNock;
Expand Down
4 changes: 2 additions & 2 deletions __test__/extensions/action-handlers/zapier-action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("zapier-action", () => {
expect(ret2.result).toBe(true);
});

describe("#onTagUpdate", async () => {
describe("#onTagUpdate", () => {
it("should bail if ZAPIER_WEBHOOK_URL is undefined", async () => {
process.env.ZAPIER_WEBHOOK_URL = undefined;
const ret = await ZapierAction.onTagUpdate(null, null, null, null, null);
Expand Down Expand Up @@ -375,7 +375,7 @@ describe("zapier-action", () => {
});
});

describe("#processAction", async () => {
describe("#processAction", () => {
let questionResponse;
let interactionStep;
let campaignContactId;
Expand Down
4 changes: 2 additions & 2 deletions __test__/extensions/contact-loaders/csv-upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const dupeContacts = [
}
];

describe("ingest-contact-loader method: csv-upload backend", async () => {
describe("ingest-contact-loader method: csv-upload backend", () => {
let testAdminUser;
let testInvite;
let testOrganization;
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("ingest-contact-loader method: csv-upload backend", async () => {
});
});

describe("ingest-contact-loader method: csv-upload frontend", async () => {
describe("ingest-contact-loader method: csv-upload frontend", () => {
let didSubmit = false;
let changeData = null;
const onSubmit = () => {
Expand Down
16 changes: 8 additions & 8 deletions __test__/server/api/campaign/campaign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ it("should save campaign canned responses across copies and match saved data", a
}
});

describe("Caching", async () => {
describe("Caching", () => {
if (r.redis && getConfig("REDIS_CONTACT_CACHE")) {
it("should not have any selects on a cached campaign when message sending", async () => {
await createScript(testAdminUser, testCampaign);
Expand All @@ -433,7 +433,7 @@ describe("Caching", async () => {
}
});

describe("Reassignments", async () => {
describe("Reassignments", () => {
it("should allow reassignments before campaign start", async () => {
// - user gets assignment todos
// - assignments are changed in different ways (with different mutations)
Expand Down Expand Up @@ -843,7 +843,7 @@ describe("Reassignments", async () => {
}, 10000); // long test can exceed default 5seconds
});

describe("Bulk Send", async () => {
describe("Bulk Send", () => {
const OLD_ENV = process.env;

beforeEach(async () => {
Expand Down Expand Up @@ -1016,7 +1016,7 @@ describe("Bulk Send", async () => {
});
});

describe("campaigns query", async () => {
describe("campaigns query", () => {
let testCampaign2;

const cursor = {
Expand Down Expand Up @@ -1212,7 +1212,7 @@ describe("all interaction steps fields travel round trip", () => {
});
});

describe("useOwnMessagingService", async () => {
describe("useOwnMessagingService", () => {
const oldEnv = process.env;
beforeEach(async () => {
await ensureOrganizationTwilioWithMessagingService(
Expand Down Expand Up @@ -1290,7 +1290,7 @@ describe("useOwnMessagingService", async () => {
});
});

describe("per-campaign phone numbers", async () => {
describe("per-campaign phone numbers", () => {
const oldEnv = process.env;
beforeAll(() => {
process.env = {
Expand All @@ -1306,7 +1306,7 @@ describe("per-campaign phone numbers", async () => {
});

it("allocates numbers to a campaign and creates a messaging service on start", async () => {
const [phoneId] = await r.knex("owned_phone_number").insert(
const [res] = await r.knex("owned_phone_number").insert(
{
organization_id: organizationId,
service: "fakeservice",
Expand All @@ -1327,7 +1327,7 @@ describe("per-campaign phone numbers", async () => {

const phoneNumber = await r
.knex("owned_phone_number")
.where("id", phoneId)
.where("id", res.id)
.first();
expect(phoneNumber.allocated_to).toEqual("campaign");
expect(phoneNumber.allocated_to_id).toEqual(testCampaign.id.toString());
Expand Down
6 changes: 3 additions & 3 deletions __test__/server/api/campaign/updateQuestionResponses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ describe("mutations.updateQuestionResponses", () => {
});
});

describe("when some of the steps have an action handler", async () => {
describe("when some of the steps have an action handler", () => {
beforeEach(async () => {
expect.extend({
objectWithId: (received, expectedObject) => {
Expand Down Expand Up @@ -703,7 +703,7 @@ describe("mutations.updateQuestionResponses", () => {
expect(ActionHandlers.rawAllActionHandlers).toHaveBeenCalledTimes(1);
expect(ActionHandlers.rawAllActionHandlers.mock.results).toEqual([
{
isThrow: false,
type: "return",
value: {
"complex-test-action": expect.objectContaining({
name: "complex-test-action"
Expand Down Expand Up @@ -958,7 +958,7 @@ describe("mutations.updateQuestionResponses", () => {
});
});

describe("when no action handlers are configured", async () => {
describe("when no action handlers are configured", () => {
beforeEach(async () => {
({
interactionSteps,
Expand Down
2 changes: 1 addition & 1 deletion __test__/server/api/editOrganization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
setupTest
} from "../../test_helpers";

describe("editOrganization", async () => {
describe("editOrganization", () => {
let startedCampaign;

beforeEach(async () => {
Expand Down
6 changes: 3 additions & 3 deletions __test__/server/api/organization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as serviceMap from "../../../src/extensions/service-vendors/service_map

const ActionHandlerFramework = require("../../../src/extensions/action-handlers");

describe("organization", async () => {
describe("organization", () => {
let testTexterUser;
let testAdminUser;
let testInvite;
Expand Down Expand Up @@ -52,7 +52,7 @@ describe("organization", async () => {
if (r.redis) r.redis.flushdb();
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT);

describe("organization query", async () => {
describe("organization query", () => {
let testCampaign2;
let testCampaign3;
let testCampaign4;
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("organization", async () => {
]);
});

describe("sorts", async () => {
describe("sorts", () => {
const runTest = async (sortBy, expectedOrderedIds) => {
variables.sortBy = sortBy;
const result = await runGql(
Expand Down
10 changes: 5 additions & 5 deletions __test__/server/api/people.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
runGql
} from "../../test_helpers";

describe("people", async () => {
describe("people", () => {
let testTexterUsers;
let testAdminUsers;
let testContacts;
Expand Down Expand Up @@ -189,7 +189,7 @@ describe("people", async () => {
if (r.redis) r.redis.flushdb();
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT);

describe("filtering", async () => {
describe("filtering", () => {
const testFiltering = async (result, expectedUsers) => {
expect(result.data.people.users.length).toEqual(expectedUsers.length);

Expand Down Expand Up @@ -356,7 +356,7 @@ describe("people", async () => {
});
});

describe("sorting", async () => {
describe("sorting", () => {
const testSortResults = async (result, expectedUsers) => {
expect(result.data.people.users.length).toEqual(expectedUsers.length);

Expand Down Expand Up @@ -422,7 +422,7 @@ describe("people", async () => {
});
});

describe("pagination", async () => {
describe("pagination", () => {
beforeEach(async () => {
cursor = {
offset: 0,
Expand Down Expand Up @@ -471,7 +471,7 @@ describe("people", async () => {
});
});

describe("permissions", async () => {
describe("permissions", () => {
it("doesn't allow texter users to retrieve people", async () => {
const result = await runGql(getUsersGql, variables, testTexterUsers[0]);
expect(result.errors).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion __test__/server/api/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("User", () => {
}).save();
});

describe("getUsers", async () => {
describe("getUsers", () => {
it("returns pageInfo.total == user.length when there's a cursor", async () => {
const users = [
await new User({
Expand Down
14 changes: 8 additions & 6 deletions __test__/server/lib/http-request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import nock from "nock";

import requestWithRetry from "../../../src/server/lib/http-request.js";

describe("requestWithRetry", async () => {
describe("requestWithRetry", () => {
let url;
let path;
let headers;
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("requestWithRetry", async () => {
nocked.done();
});

describe("validate status", async () => {
describe("validate status", () => {
let nocked;
beforeEach(async () => {
nocked = nock(url, {
Expand All @@ -62,7 +62,7 @@ describe("requestWithRetry", async () => {
.reply(201, "Nevertheless it was persisted.");
});

describe("successful status validation", async () => {
describe("successful status validation", () => {
it("validStatuses is provided", async () => {
const result = await requestWithRetry(`${url}${path}`, {
method: "POST",
Expand Down Expand Up @@ -90,7 +90,7 @@ describe("requestWithRetry", async () => {
});
});

describe("unsuccessful status validation", async () => {
describe("unsuccessful status validation", () => {
it("validStatuses is provided", async () => {
let error;

Expand Down Expand Up @@ -137,7 +137,7 @@ describe("requestWithRetry", async () => {
});
});

describe("when the request times out", async () => {
describe("when the request times out", () => {
it("retries", async () => {
let error;
const nocked = nock(url)
Expand Down Expand Up @@ -199,10 +199,11 @@ describe("requestWithRetry", async () => {
/Error: Request id .+ failed; timeout after 500ms/
);
nocked.done();
nock.abortPendingRequests(); // Close open Jest handle due to timeout
}
});

describe("when retries is 0", async () => {
describe("when retries is 0", () => {
let error;
it("it doesn't retry", async () => {
const nocked = nock(url)
Expand Down Expand Up @@ -241,6 +242,7 @@ describe("requestWithRetry", async () => {
/Error: Request id .+ failed; timeout after 100ms/
);
nocked.done();
nock.abortPendingRequests(); // Close open Jest handle due to timeout
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion __test__/server/models/cacheable_queries/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import { r, cacheableData } from "../../../../src/server/models";

describe("cacheable_queries.user", async () => {
describe("cacheable_queries.user", () => {
let queryLog;
let testAdminUser;
let testInvite;
Expand Down
2 changes: 1 addition & 1 deletion __test__/server/models/question-response.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "../../test_helpers";
import { r, cacheableData } from "../../../src/server/models";

describe("questionResponse cacheableData methods", async () => {
describe("questionResponse cacheableData methods", () => {
let initData;
beforeEach(async () => {
await setupTest();
Expand Down
Loading

0 comments on commit 9ce5253

Please sign in to comment.