Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
anbraten committed Nov 6, 2023
1 parent 0225b1e commit 319956d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/server/src/api/endpoints/payment_method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ describe('Payment-method endpoints', () => {
paymentProviderId: '123',
};

const deleteMock = vi.fn();
const persistAndFlush = vi.fn();
const removeAndFlush = vi.fn();

vi.spyOn(database, 'database', 'get').mockReturnValue({
paymentMethods: {
findOne() {
return Promise.resolve(new PaymentMethod(paymentMethodData));
return Promise.resolve(new PaymentMethod({ ...paymentMethodData, customer: testData.customer }));
},
},
projects: {
Expand All @@ -200,7 +201,8 @@ describe('Payment-method endpoints', () => {
},
},
em: {
removeAndFlush: deleteMock,
persistAndFlush,
removeAndFlush,
},
} as unknown as database.Database);

Expand All @@ -221,7 +223,9 @@ describe('Payment-method endpoints', () => {
const paymentMethodResponse: { ok: boolean } = response.json();
expect(paymentMethodResponse).toBeDefined();
expect(paymentMethodResponse).toStrictEqual({ ok: true });
expect(deleteMock).toBeCalledTimes(1);
expect(deleteMock).toHaveBeenCalledWith(paymentMethodData);
expect(removeAndFlush).toBeCalledTimes(1);
expect(removeAndFlush).toHaveBeenCalledWith(paymentMethodData);

expect(persistAndFlush).toBeCalledTimes(1);
});
});

0 comments on commit 319956d

Please sign in to comment.