UI: Use specific date in clients activity test (#19419)

* Use specific date in clients activity test

* Remove add and subtracting months twice
This commit is contained in:
Kianna 2023-03-01 13:41:50 -08:00 committed by GitHub
parent 09057073ae
commit 6e38bb4922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -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 = {