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

Freeze moment for testing #301

Open
AndreJoaquim opened this issue Mar 21, 2019 · 1 comment
Open

Freeze moment for testing #301

AndreJoaquim opened this issue Mar 21, 2019 · 1 comment

Comments

@AndreJoaquim
Copy link

AndreJoaquim commented Mar 21, 2019

Hey! I've used this add-on for a long time and I has served my needs perfectly.

However, one thing that I'd like to see included in this add-on is a helper to freeze moment (i.e. override moment.now) in tests, namely acceptance tests. Below I show what the API could look like:

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { setupMoment } from 'ember-moment/test-support';

module('Integration | Component | x-event/date', function(hooks) {
  setupRenderingTest(hooks);
  setupMoment(hooks, '2042-01-01');

  test('it renders', async function(assert) {
    // This component only displays today's date in the format "DD/MM/YYYY"
    await render(hbs`{{x-event/date}}`);

    assert.dom(this.element).hasText('01/01/2042');
  });
});

This would allow (more) deterministic tests, instead of relying of always getting today's date to see if the behaviour(s) is(are) correct.

What do you think about this feature? Thanks! 😄

@jasonmit
Copy link
Collaborator

@AndreJoaquim I love it! Feel free to send a PR (or anyone for that matter) if you have the cycles!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants