Skip to content

Commit

Permalink
Revert "Mocking of Date"
Browse files Browse the repository at this point in the history
This reverts commit b7a8ed2.
  • Loading branch information
zfir committed Jul 14, 2024
1 parent b7a8ed2 commit afc51ad
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 159 deletions.
140 changes: 0 additions & 140 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@types/htmlbars-inline-precompile": "^3.0.0",
"@types/qunit": "^2.19.10",
"@types/rsvp": "^4.0.9",
"@types/sinon": "^17.0.3",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^8.2.2",
"ember-auto-import": "^2.7.0",
Expand Down Expand Up @@ -97,7 +96,6 @@
"prettier": "^3.1.1",
"qunit": "^2.20.0",
"qunit-dom": "^2.0.0",
"sinon": "^18.0.0",
"stylelint": "^15.11.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-prettier": "^4.1.0",
Expand Down
19 changes: 2 additions & 17 deletions tests/integration/components/user-info-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { find, render, settled, waitFor, waitUntil } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import sinon from 'sinon';

module('Integration | Component | user-info', function (hooks) {
setupRenderingTest(hooks);

let clock: sinon.SinonFakeTimers;
let date: Date;

hooks.beforeEach(function () {
date = new Date('1999-01-01T00:00:00Z');
clock = sinon.useFakeTimers(date.getTime());
});

hooks.afterEach(function () {
clock.restore();
});

// Fails
// test('it fails without await settled to show user info', async function (assert) {
// await render(hbs`<UserInfo />`);
Expand Down Expand Up @@ -51,7 +38,6 @@ module('Integration | Component | user-info', function (hooks) {
// Passes
test('it passes with waitUntil to show updated text', async function (assert) {
await render(hbs`<UserInfo />`);
clock.tick(2000);

const found = await waitUntil(() => {
const div = find('.user-info') as HTMLDivElement;
Expand All @@ -66,17 +52,16 @@ module('Integration | Component | user-info', function (hooks) {
// await render(hbs`<UserInfo />`);

// const div = find('.date') as HTMLDivElement;
// assert.true(div.textContent?.includes("Fri Jan 01 1999 04:00:02 GMT+0400 (Mauritius Standard Time)"));
// assert.true(div.textContent?.includes(new Date() as unknown as string));
// });

// Passes
test('it passes with waitFor to show date', async function (assert) {
await render(hbs`<UserInfo />`);
clock.tick(2000);

await waitFor('.date', { timeout: 3000 });
const div = find('.date') as HTMLDivElement;

assert.true(div.textContent?.includes("Fri Jan 01 1999 04:00:02 GMT+0400 (Mauritius Standard Time)"));
assert.true(div.textContent?.includes(new Date() as unknown as string));
});
});

0 comments on commit afc51ad

Please sign in to comment.