|
1 | 1 | import { clickByName, render } from '@1024pix/ember-testing-library';
|
2 | 2 | // eslint-disable-next-line no-restricted-imports
|
3 |
| -import { find } from '@ember/test-helpers'; |
| 3 | +import { find, findAll } from '@ember/test-helpers'; |
4 | 4 | import { hbs } from 'ember-cli-htmlbars';
|
5 | 5 | import { t } from 'ember-intl/test-support';
|
6 | 6 | import ModuleGrain from 'mon-pix/components/module/grain/grain';
|
@@ -169,6 +169,75 @@ module('Integration | Component | Module | Grain', function (hooks) {
|
169 | 169 | });
|
170 | 170 |
|
171 | 171 | module('when component is an element', function () {
|
| 172 | + module('when element is a custom element', function () { |
| 173 | + test('should display a "CustomElement" element', async function (assert) { |
| 174 | + // given |
| 175 | + const store = this.owner.lookup('service:store'); |
| 176 | + const customElement = { |
| 177 | + type: 'custom', |
| 178 | + tagName: 'qcu-image', |
| 179 | + props: { |
| 180 | + name: "Liste d'applications", |
| 181 | + maxChoicesPerLine: 3, |
| 182 | + imageChoicesSize: 'icon', |
| 183 | + choices: [ |
| 184 | + { |
| 185 | + name: 'Google', |
| 186 | + image: { |
| 187 | + width: 534, |
| 188 | + height: 544, |
| 189 | + loading: 'lazy', |
| 190 | + decoding: 'async', |
| 191 | + src: 'https://epreuves.pix.fr/_astro/Google.B1bcY5Go_1BynY8.svg', |
| 192 | + }, |
| 193 | + }, |
| 194 | + { |
| 195 | + name: 'LibreOffice Writer', |
| 196 | + image: { |
| 197 | + width: 205, |
| 198 | + height: 246, |
| 199 | + loading: 'lazy', |
| 200 | + decoding: 'async', |
| 201 | + src: 'https://epreuves.pix.fr/_astro/writer.3bR8N2DK_Z1iWuJ9.webp', |
| 202 | + }, |
| 203 | + }, |
| 204 | + { |
| 205 | + name: 'Explorateur', |
| 206 | + image: { |
| 207 | + width: 128, |
| 208 | + height: 128, |
| 209 | + loading: 'lazy', |
| 210 | + decoding: 'async', |
| 211 | + src: 'https://epreuves.pix.fr/_astro/windows-file-explorer.CnF8MYwI_23driA.webp', |
| 212 | + }, |
| 213 | + }, |
| 214 | + { |
| 215 | + name: 'Geogebra', |
| 216 | + image: { |
| 217 | + width: 640, |
| 218 | + height: 640, |
| 219 | + loading: 'lazy', |
| 220 | + decoding: 'async', |
| 221 | + src: 'https://epreuves.pix.fr/_astro/geogebra.CZH9VYqc_19v4nj.webp', |
| 222 | + }, |
| 223 | + }, |
| 224 | + ], |
| 225 | + }, |
| 226 | + }; |
| 227 | + const grain = store.createRecord('grain', { |
| 228 | + title: 'Grain title', |
| 229 | + components: [{ type: 'element', element: customElement }], |
| 230 | + }); |
| 231 | + |
| 232 | + // when |
| 233 | + await render(<template><ModuleGrain @grain={{grain}} /></template>); |
| 234 | + |
| 235 | + // then |
| 236 | + assert.strictEqual(findAll('.element-custom').length, 1); |
| 237 | + assert.strictEqual(findAll('qcu-image').length, 1); |
| 238 | + }); |
| 239 | + }); |
| 240 | + |
172 | 241 | module('when element is a text', function () {
|
173 | 242 | test('should display text element', async function (assert) {
|
174 | 243 | // given
|
|
0 commit comments