{"size": 2194, "ext": "js", "max_stars_repo_path": "tests/integration/helpers/intl-relative-time-format-test.js", "max_stars_repo_name": "robert-allan-frank/ember-intl-fns", "max_stars_repo_stars_event_min_datetime": "2019-11-02T21:14:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-02T21:14:19.000Z", "max_issues_repo_path": "tests/integration/helpers/intl-relative-time-format-test.js", "max_issues_repo_name": "robert-allan-frank/ember-intl-fns", "max_issues_repo_issues_event_min_datetime": "2019-11-02T22:18:54.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-03T21:09:47.000Z", "max_forks_repo_path": "tests/integration/helpers/intl-relative-time-format-test.js", "max_forks_repo_name": "robert-allan-frank/ember-intl-fns", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 26.756097561, "max_line_length": 80, "alphanum_fraction": 0.6267092069}
import { render } from '@ember/test-helpers';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import { module, test } from 'qunit';

module('Integration | Helper | intl-relative-time-format', function(hooks) {
  setupRenderingTest(hooks);

  test('can format relative time as auto', async function(assert) {
    const locale = 'en-US';
    const value = -1;
    const unit = 'day';
    const hash = {
      localeMatcher: 'best fit',
      numeric: 'auto',
      style: 'short'
    };

    this.set('locale', locale);
    this.set('value', value);
    this.set('unit', unit);
    this.set('hash', hash);

    await render(hbs`{{intl-relative-time-format locale value unit hash}}`);

    assert.equal(this.element.textContent.trim(), 'yesterday');
  });

  test('can format relative time as always', async function(assert) {
    const locale = 'en-US';
    const value = -1;
    const unit = 'day';
    const hash = {
      localeMatcher: 'best fit',
      numeric: 'always',
      style: 'long'
    };

    this.set('locale', locale);
    this.set('value', value);
    this.set('unit', unit);
    this.set('hash', hash);

    await render(hbs`{{intl-relative-time-format locale value unit hash}}`);

    assert.equal(this.element.textContent.trim(), '1 day ago');
  });

  test('can format relative time with default options', async function(assert) {
    const locale = 'en-US';
    const value = 10;
    const unit = 'minute';

    this.set('locale', locale);
    this.set('value', value);
    this.set('unit', unit);

    await render(hbs`{{intl-relative-time-format locale value unit}}`);

    assert.equal(this.element.textContent.trim(), 'in 10 minutes');
  });

  test('can format relative time with no intl support', async function(assert) {
    const intl = window.Intl;
    window.Intl = null;

    const locale = 'en-US';
    const value = 10;
    const unit = 'minute';

    this.set('locale', locale);
    this.set('value', value);
    this.set('unit', unit);

    await render(hbs`{{intl-relative-time-format locale value unit}}`);

    window.Intl = intl;

    assert.equal(this.element.textContent.trim(), '10 minute');
  });
});
