diff --git a/orga/tests/integration/components/campaign/activity/dashboard-test.js b/orga/tests/integration/components/campaign/activity/dashboard-test.js new file mode 100644 index 00000000000..1d6711352dd --- /dev/null +++ b/orga/tests/integration/components/campaign/activity/dashboard-test.js @@ -0,0 +1,46 @@ +import { render } from '@1024pix/ember-testing-library'; +import { hbs } from 'ember-cli-htmlbars'; +import { module, test } from 'qunit'; +import sinon from 'sinon'; + +import setupIntlRenderingTest from '../../../../helpers/setup-intl-rendering'; + +module('Integration | Component | Campaign::Activity::Dashboard', (hooks) => { + setupIntlRenderingTest(hooks); + + hooks.beforeEach(function () { + const store = this.owner.lookup('service:store'); + const adapterStub = { + getParticipationsByStatus: sinon + .stub() + .withArgs('1') + .resolves({ + data: { + attributes: { + started: 1, + completed: 2, + shared: 3, + }, + }, + }), + getParticipationsByDay: sinon.stub().resolves({ + data: { + attributes: { + 'started-participations': [], + 'shared-participations': [], + }, + }, + }), + }; + sinon.stub(store, 'adapterFor'); + store.adapterFor.withArgs('campaign-stats').returns(adapterStub); + }); + + test('it displays right data', async function (assert) { + this.set('campaign', { id: '1' }); + + const screen = await render(hbs``); + + assert.ok(screen.getByText('6')); + }); +}); diff --git a/orga/tests/unit/components/campaign/activity/dashboard-test.js b/orga/tests/unit/components/campaign/activity/dashboard-test.js deleted file mode 100644 index a4db38e4dac..00000000000 --- a/orga/tests/unit/components/campaign/activity/dashboard-test.js +++ /dev/null @@ -1,43 +0,0 @@ -import { setupTest } from 'ember-qunit'; -import { module, test } from 'qunit'; -import sinon from 'sinon'; - -import createGlimmerComponent from '../../../../helpers/create-glimmer-component'; - -module('Unit | Component | Campaign::Activity::Dashboard', (hooks) => { - setupTest(hooks); - let component, dataFetcher; - - hooks.beforeEach(function () { - const store = this.owner.lookup('service:store'); - const adapter = store.adapterFor('campaign-stats'); - dataFetcher = sinon.stub(adapter, 'getParticipationsByStatus'); - - dataFetcher.resolves({ - data: { - attributes: { - started: 1, - completed: 1, - shared: 1, - }, - }, - }); - }); - - test('should fill data', async function (assert) { - // when - component = await createGlimmerComponent('component:campaign/activity/dashboard', { - campaign: { id: 1 }, - }); - - // then - - assert.strictEqual(component.total, 3); - assert.strictEqual(component.shared, 1); - assert.deepEqual(component.participantCountByStatus, [ - ['started', 1], - ['completed', 1], - ['shared', 1], - ]); - }); -}); diff --git a/orga/tests/unit/components/campaign/charts/participants-by-day-test.js b/orga/tests/unit/components/campaign/charts/participants-by-day-test.js index d1651b5a492..5a4918e7ffe 100644 --- a/orga/tests/unit/components/campaign/charts/participants-by-day-test.js +++ b/orga/tests/unit/components/campaign/charts/participants-by-day-test.js @@ -14,25 +14,6 @@ module('Unit | Component | Campaign::Charts::ParticipantsByDay', (hooks) => { dataFetcher = sinon.stub(adapter, 'getParticipationsByDay'); }); - test('should pass without data', async function (assert) { - // given - dataFetcher.resolves({ - data: { - attributes: { - 'started-participations': [], - 'shared-participations': [], - }, - }, - }); - - // when - component = await createGlimmerComponent('component:campaign/charts/participants-by-day'); - - // then - assert.deepEqual(component.startedDatasets, []); - assert.deepEqual(component.sharedDatasets, []); - }); - test('should fill the default datasets', async function (assert) { // given dataFetcher.resolves({