import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import tHelper from "ember-i18n/helper";
import Ember from 'ember';

// Stub i18n service
const i18nStub = Ember.Service.extend({
    t: function(word) {
        const translated = {
            'searchablePreprints': `searchable preprints`,
        };
        return translated[word];
    }
});
moduleForComponent('total-share-results', 'Integration | Component | total share results', {
  integration: true,
  beforeEach() {
      this.registry.register('helper:t', tHelper);
      this.register('service:i18n', i18nStub);
      this.inject.service('i18n', { as: 'i18n' });
  }
});

test('it renders', function(assert) {

  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });
    this.set('shareTotal', 100);
    this.set('shareTotalText', 'searchablePreprints');

    this.render(hbs`{{total-share-results
        shareTotal=shareTotal
        shareTotalText=shareTotalText
    }}`);
    assert.strictEqual(this.$('span')[0].innerText, 'searchable preprints');
});

import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('total-share-results', 'Integration | Component | total share results', {
  integration: true
});

test('it renders', function(assert) {

  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });
    this.set('shareTotal', 100);
    this.set('shareTotalText', 'searchable preprints');

    this.render(hbs`{{total-share-results
        shareTotal=shareTotal
        shareTotalText=shareTotalText
    }}`);
    assert.ok(this.$().text().trim().includes('100 searchable preprints'));
});

--- 
+++ 
@@ -1,24 +1,8 @@
 import { moduleForComponent, test } from 'ember-qunit';
 import hbs from 'htmlbars-inline-precompile';
-import tHelper from "ember-i18n/helper";
-import Ember from 'ember';
 
-// Stub i18n service
-const i18nStub = Ember.Service.extend({
-    t: function(word) {
-        const translated = {
-            'searchablePreprints': `searchable preprints`,
-        };
-        return translated[word];
-    }
-});
 moduleForComponent('total-share-results', 'Integration | Component | total share results', {
-  integration: true,
-  beforeEach() {
-      this.registry.register('helper:t', tHelper);
-      this.register('service:i18n', i18nStub);
-      this.inject.service('i18n', { as: 'i18n' });
-  }
+  integration: true
 });
 
 test('it renders', function(assert) {
@@ -26,11 +10,11 @@
   // Set any properties with this.set('myProperty', 'value');
   // Handle any actions with this.on('myAction', function(val) { ... });
     this.set('shareTotal', 100);
-    this.set('shareTotalText', 'searchablePreprints');
+    this.set('shareTotalText', 'searchable preprints');
 
     this.render(hbs`{{total-share-results
         shareTotal=shareTotal
         shareTotalText=shareTotalText
     }}`);
-    assert.strictEqual(this.$('span')[0].innerText, 'searchable preprints');
+    assert.ok(this.$().text().trim().includes('100 searchable preprints'));
 });
Add stub for i18n service.
