Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of UI: Use specific date in clients activity test into release/1.13.x #19423

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing that I wrote to moths still makes me laugh 😂

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