From c9cf54cbf925101b5760911be2ea6724dca8aedc Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Sun, 21 Jun 2020 21:26:03 +0200 Subject: [PATCH] fix: Fix and test expense publish. --- server/tests/routes/expenses.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/tests/routes/expenses.test.js b/server/tests/routes/expenses.test.js index 5ef1fbde8..7ba1bb63d 100644 --- a/server/tests/routes/expenses.test.js +++ b/server/tests/routes/expenses.test.js @@ -716,4 +716,24 @@ describe('routes: /expenses/', () => { expect(foundExpenses.length).equals(0); }) }); + + describe('POST: `/api/expenses/:id/publish`', () => { + it('Should publish the given expense.', async () => { + const expense = await tenantFactory.create('expense', { + published: 0, + }); + + const res = await request() + .post(`/api/expenses/${expense.id}/publish`) + .set('x-access-token', loginRes.body.token) + .set('organization-id', tenantWebsite.organizationId) + .send(); + + const foundExpense = await Expense.tenant().query() + .where('id', expense.id).first(); + + expect(res.status).equals(200); + expect(foundExpense.published).equals(1); + }); + }); });