Merge pull request #3327 from github/robertbrignull/VsCodeWindow
Introduce VsCodeWindow to provide types for the fields we're reading/writing
This commit is contained in:
@@ -29,7 +29,7 @@ describe(CodePaths.name, () => {
|
|||||||
|
|
||||||
await userEvent.click(screen.getByText("Show paths"));
|
await userEvent.click(screen.getByText("Show paths"));
|
||||||
|
|
||||||
expect((window as any).vsCodeApi.postMessage).toHaveBeenCalledWith({
|
expect(window.vsCodeApi.postMessage).toHaveBeenCalledWith({
|
||||||
t: "showDataFlowPaths",
|
t: "showDataFlowPaths",
|
||||||
dataFlowPaths: {
|
dataFlowPaths: {
|
||||||
codeFlows: createMockCodeFlows(),
|
codeFlows: createMockCodeFlows(),
|
||||||
|
|||||||
@@ -16,14 +16,12 @@ Object.defineProperty(window, "matchMedia", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Used by Primer React
|
// Used by Primer React
|
||||||
(window as any).CSS = {
|
window.CSS.supports = jest.fn().mockResolvedValue(false);
|
||||||
supports: jest.fn().mockResolvedValue(false),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Store this on the window so we can mock it
|
// Store this on the window so we can mock it
|
||||||
(window as any).vsCodeApi = {
|
window.vsCodeApi = {
|
||||||
postMessage: jest.fn(),
|
postMessage: jest.fn(),
|
||||||
setState: jest.fn(),
|
setState: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
(window as any).acquireVsCodeApi = () => (window as any).vsCodeApi;
|
window.acquireVsCodeApi = () => window.vsCodeApi;
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ describe(RepoRow.name, () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect((window as any).vsCodeApi.postMessage).toHaveBeenCalledWith({
|
expect(window.vsCodeApi.postMessage).toHaveBeenCalledWith({
|
||||||
t: "requestRepositoryResults",
|
t: "requestRepositoryResults",
|
||||||
repositoryFullName: "octodemo/hello-world-1",
|
repositoryFullName: "octodemo/hello-world-1",
|
||||||
});
|
});
|
||||||
|
|||||||
11
extensions/ql-vscode/src/view/vscode-window.ts
Normal file
11
extensions/ql-vscode/src/view/vscode-window.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { VsCodeApi } from "./vscode-api";
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
CSS: {
|
||||||
|
supports: () => Promise<boolean>;
|
||||||
|
};
|
||||||
|
vsCodeApi: VsCodeApi;
|
||||||
|
acquireVsCodeApi: () => VsCodeApi;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user