-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
mon-pix/app/components/module/element/flashcards-intro-card.gjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import { t } from 'ember-intl'; | ||
|
||
<template> | ||
<div class="element-flashcards__intro-card"> | ||
{{#if @introImage}} | ||
<div class="element-flashcards__intro-card__image"> | ||
<img src={{@introImage.url}} alt="" /> | ||
</div> | ||
{{/if}} | ||
|
||
<div class="element-flashcards__intro-card__text"> | ||
<p class="element-flashcards__intro-card__title">{{@title}}</p> | ||
</div> | ||
|
||
<div class="element-flashcards__intro-card__footer"> | ||
<PixButton @triggerAction={{@onStart}} @variant="primary" @size="small"> | ||
{{t "pages.modulix.buttons.flashcards.start"}} | ||
</PixButton> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
mon-pix/tests/integration/components/module/flashcards-intro-card_test.gjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { clickByName, render } from '@1024pix/ember-testing-library'; | ||
import { t } from 'ember-intl/test-support'; | ||
import ModulixFlashcardsIntroCard from 'mon-pix/components/module/element/flashcards-intro-card'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; | ||
|
||
module('Integration | Component | Module | Flashcards Intro Card', function (hooks) { | ||
setupIntlRenderingTest(hooks); | ||
|
||
test('should display an intro card', async function (assert) { | ||
// given | ||
const introImage = { | ||
url: 'https://images.pix.fr/modulix/bien-ecrire-son-adresse-mail-explication-les-parties-dune-adresse-mail.svg', | ||
}; | ||
const title = 'Introduction à la poésie'; | ||
|
||
// when | ||
const screen = await render( | ||
<template><ModulixFlashcardsIntroCard @introImage={{introImage}} @title={{title}} /></template>, | ||
); | ||
|
||
// then | ||
assert.ok(screen.getByText('Introduction à la poésie')); | ||
assert.strictEqual( | ||
screen.getByRole('presentation').getAttribute('src'), | ||
'https://images.pix.fr/modulix/bien-ecrire-son-adresse-mail-explication-les-parties-dune-adresse-mail.svg', | ||
); | ||
assert.dom(screen.getByRole('button', { name: t('pages.modulix.buttons.flashcards.start') })).exists(); | ||
}); | ||
|
||
test('should not display image if not provided', async function (assert) { | ||
// given | ||
const introImage = undefined; | ||
const title = 'Introduction à la poésie'; | ||
|
||
// when | ||
const screen = await render( | ||
<template><ModulixFlashcardsIntroCard @introImage={{introImage}} @title={{title}} /></template>, | ||
); | ||
|
||
// then | ||
assert.dom(screen.queryByRole('img')).doesNotExist(); | ||
}); | ||
|
||
module('when we click on "Commencer"', function () { | ||
test('should call the onStart method', async function (assert) { | ||
// given | ||
const introImage = undefined; | ||
const title = 'Introduction à la poésie'; | ||
const onStartStub = sinon.stub(); | ||
|
||
await render( | ||
<template> | ||
<ModulixFlashcardsIntroCard @introImage={{introImage}} @title={{title}} @onStart={{onStartStub}} /> | ||
</template>, | ||
); | ||
|
||
// when | ||
await clickByName(t('pages.modulix.buttons.flashcards.start')); | ||
|
||
// then | ||
assert.true(onStartStub.calledOnce); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters