Skip to content

Commit

Permalink
Fix options.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx committed Oct 7, 2023
1 parent 41fa458 commit 0793f60
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions packages/mountable/src/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ describe("canonicalizeMountOptions()", () => {
},
requirements: [],
archives: [],
onProgress: expect.any(Function),
onLoad: expect.any(Function),
onError: expect.any(Function),
...makeToastKernelCallbacks(),
});
});

Expand Down Expand Up @@ -98,9 +96,7 @@ describe("canonicalizeMountOptions()", () => {
},
},
archives: [],
onProgress: expect.any(Function),
onLoad: expect.any(Function),
onError: expect.any(Function),
...makeToastKernelCallbacks(),
});
});

Expand Down Expand Up @@ -146,9 +142,7 @@ describe("canonicalizeMountOptions()", () => {
options: {},
},
],
onProgress: expect.any(Function),
onLoad: expect.any(Function),
onError: expect.any(Function),
...makeToastKernelCallbacks(),
});
});

Expand All @@ -169,9 +163,7 @@ describe("canonicalizeMountOptions()", () => {
},
},
archives: [],
onProgress: expect.any(Function),
onLoad: expect.any(Function),
onError: expect.any(Function),
...makeToastKernelCallbacks(),
});
});

Expand All @@ -185,19 +177,17 @@ describe("canonicalizeMountOptions()", () => {
entrypoint: "streamlit_app.py",
files: {},
archives: [],
onProgress: expect.any(Function),
onLoad: expect.any(Function),
onError: expect.any(Function),
...makeToastKernelCallbacks(),
});
});

it("wraps the `onError` option and also shows the original toast callback if `true` returned", () => {
it("wraps the `onError` option and also delegates to the original toast callback if `true` returned", () => {
const toastCallbacks = makeToastKernelCallbacks();

const error = new Error("foo");

const onError = jest.fn();
const options = canonicalizeMountOptions({ onError });

const error = new Error("foo");
options.onError!(error);
expect(onError).toHaveBeenCalledWith(error);
expect(toastCallbacks.onError).toHaveBeenCalledWith(error);
Expand All @@ -206,10 +196,10 @@ describe("canonicalizeMountOptions()", () => {
it("wraps the `onError` option but prevents the toast if `false` returned", () => {
const toastCallbacks = makeToastKernelCallbacks();

const error = new Error("foo");

const onError = jest.fn(() => false);
const options = canonicalizeMountOptions({ onError });

const error = new Error("foo");
options.onError!(error);
expect(onError).toHaveBeenCalledWith(error);
expect(toastCallbacks.onError).not.toHaveBeenCalled();
Expand Down

0 comments on commit 0793f60

Please sign in to comment.