Skip to content

Commit

Permalink
Fix UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin MOUTY committed Sep 27, 2024
1 parent 4ed680c commit 42f45b7
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/codemirror/lang-filter/complete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('filter completion', () => {
let mockPost: (url: string, body?: {}, params?: string) => Promise<FetchResponse<ApiCompleteResult>>;

// Use the mocked DataSource class directly
const DataSource = require('./datasource').DataSource;
const DataSource = require('../../datasource').DataSource;
const dataSource = new DataSource(); // No need to pass instanceSettings

async function get(doc: string): Promise<CompletionResult> {
Expand Down Expand Up @@ -109,7 +109,22 @@ describe('filter completion', () => {
throw new Error(`unhandled what: ${body.what}`);
}
}
jest.mock('./datasource', () => {



jest.mock('../../datasource', () => {

mockPost = jest.fn().mockImplementation((url:string, b: string) => {

Check failure on line 117 in src/codemirror/lang-filter/complete.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint and unit tests

Expected a space after the ':'
const body: Body = JSON.parse(b);
requestBody = body;
const data = mockedResults(body);
const mockResponse = {
ok: true,
data: data,
};
return Promise.resolve(mockResponse as unknown as Response);
});

return {
DataSource: jest.fn().mockImplementation(() => {
return {
Expand All @@ -126,18 +141,6 @@ describe('filter completion', () => {
requestBody = undefined;
});

beforeEach(() => {
mockPost = jest.fn().mockImplementation((b: string, options: RequestInit | undefined) => {
const body: Body = JSON.parse(b);
requestBody = body;
const data = mockedResults(body);
const mockResponse = {
ok: true,
data: data,
};
return Promise.resolve(mockResponse as unknown as Response);
});
});

it('completes column names', async () => {
const { from, to, options } = await get('S|');
Expand Down

0 comments on commit 42f45b7

Please sign in to comment.