From f67a764698c147f8e80528466a6978a5148b3148 Mon Sep 17 00:00:00 2001 From: Kianna <30884335+kiannaquach@users.noreply.github.com> Date: Wed, 1 Mar 2023 21:41:50 +0000 Subject: [PATCH] backport of commit 7ef729708b29112db885d0f77ef55c2d7409a1f4 --- ui/tests/unit/adapters/clients-activity-test.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ui/tests/unit/adapters/clients-activity-test.js b/ui/tests/unit/adapters/clients-activity-test.js index 64da61d29318..1d67df047894 100644 --- a/ui/tests/unit/adapters/clients-activity-test.js +++ b/ui/tests/unit/adapters/clients-activity-test.js @@ -9,10 +9,11 @@ module('Unit | Adapter | clients activity', function (hooks) { setupMirage(hooks); hooks.beforeEach(function () { + const date = new Date(); this.store = this.owner.lookup('service:store'); this.modelName = 'clients/activity'; - this.startDate = subMonths(new Date(), 6); - this.endDate = new Date(); + this.startDate = subMonths(date, 6); + this.endDate = date; this.readableUnix = (unix) => parseAPITimestamp(fromUnixTime(unix).toISOString(), 'MMMM dd yyyy'); }); @@ -63,9 +64,9 @@ module('Unit | Adapter | clients activity', function (hooks) { test('it formats end_time only if only start_time is a timestamp string', async function (assert) { assert.expect(2); - const twoMothsAgo = subMonths(this.endDate, 2); - const month = twoMothsAgo.getMonth() - 2; - const year = twoMothsAgo.getFullYear(); + const twoMonthsAgo = subMonths(this.endDate, 2); + const month = twoMonthsAgo.getMonth(); + const year = twoMonthsAgo.getFullYear(); const dayOfMonth = format(lastDayOfMonth(new Date(year, month, 10)), 'dd'); const queryParams = { start_time: { @@ -95,9 +96,9 @@ module('Unit | Adapter | clients activity', function (hooks) { assert.expect(2); const startDate = subMonths(this.startDate, 2); const endDate = addMonths(this.endDate, 2); - const startMonth = startDate.getMonth() + 2; + const startMonth = startDate.getMonth(); const startYear = startDate.getFullYear(); - const endMonth = endDate.getMonth() - 2; + const endMonth = endDate.getMonth(); const endYear = endDate.getFullYear(); const endDay = format(lastDayOfMonth(new Date(endYear, endMonth, 10)), 'dd'); const queryParams = {