Skip to content

Commit

Permalink
xo
Browse files Browse the repository at this point in the history
  • Loading branch information
Den1552 committed Oct 25, 2024
1 parent 5b38999 commit a160aa2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
14 changes: 6 additions & 8 deletions tests/unit/ct-completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type SpyInstance,
beforeEach,
} from "vitest";
import axios from "axios";
import { getEnviroNameFromTestScript } from "../../langServer/serverUtilities";
import { getCodedTestCompletionData } from "../../langServer/ctCompletions";
import {
Expand All @@ -24,7 +25,6 @@ import {
prepareCodedTestCompletion,
setupDiagnosticTest,
} from "./utils";
import axios from "axios";

const expectedReceivedData = [
{
Expand Down Expand Up @@ -331,13 +331,11 @@ describe("Testing pythonUtilities (valid)", () => {
mockAxiosPost.mockRejectedValueOnce(responseBody);
} else {
// Simulate a successful response
mockAxiosPost.mockImplementation(async () =>
Promise.resolve({
data: responseBody,
status,
statusText,
})
);
mockAxiosPost.mockImplementation(async () => ({
data: responseBody,
status,
statusText,
}));
}
};

Expand Down
23 changes: 9 additions & 14 deletions tests/unit/vcast-server.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import axios from "axios";
import { describe, test, expect, vi, afterEach } from "vitest";
import {
closeConnection,
Expand All @@ -17,8 +18,6 @@ import {
} from "../../src-common/vcastServer";
import { pythonErrorCodes } from "../../src-common/vcastServerTypes";

import axios from "axios";

// Mock axios
vi.mock("axios");
const mockAxiosPost = vi.mocked(axios.post);
Expand All @@ -32,13 +31,11 @@ const mockAxios = (
status = 200,
statusText = "OK"
) => {
mockAxiosPost.mockImplementation(async () =>
Promise.resolve({
data: responseBody,
status,
statusText,
})
);
mockAxiosPost.mockImplementation(async () => ({
data: responseBody,
status,
statusText,
}));
};

describe("test server functions", () => {
Expand Down Expand Up @@ -170,11 +167,9 @@ describe("test server functions", () => {
expectedLogMessage
);

await terminateServerProcessing("Error string")
.then(() => {})
.catch((error) => {
console.error("Failed to terminate server:", error);
});
await terminateServerProcessing("Error string").catch((error) => {
console.error("Failed to terminate server:", error);
});

expect(mockTerminateCallback).toHaveBeenCalledOnce();
expect(mockTerminateCallback).toHaveBeenCalledWith("Error string");
Expand Down

0 comments on commit a160aa2

Please sign in to comment.