Skip to content

Commit

Permalink
UI: Use specific date in clients activity test (#19419)
Browse files Browse the repository at this point in the history
* Use specific date in clients activity test

* Remove add and subtracting months twice
  • Loading branch information
kiannaquach authored Mar 1, 2023
1 parent cf6be21 commit 7ef7297
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ui/tests/unit/adapters/clients-activity-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 7ef7297

Please sign in to comment.