adopted-ember-addons / adopted-ember-addons/ember-moment

Freeze moment for testing

未關閉
#301 1 則留言 6 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
JavaScript
星號
398
分支
120
PR 合併指標
30 天內沒有已合併 PR

描述

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:

```js
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! 😄

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。