Skip to content

Commit

Permalink
Merge pull request #1 from oreqizer/main
Browse files Browse the repository at this point in the history
Add test for @AnimationData
  • Loading branch information
22a authored Apr 12, 2024
2 parents 8fc30c7 + 030ec18 commit 1c63810
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test-app/tests/integration/components/fixtures/data.ts

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions test-app/tests/integration/components/lottie-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { setupRenderingTest } from 'ember-qunit';
import { clearRender, find, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import type { TestContext as TestContextBase } from '@ember/test-helpers';
import exampleData from './fixtures/data';

import window from 'ember-window-mock';
import { setupWindowMock } from 'ember-window-mock/test-support';
Expand All @@ -11,6 +12,7 @@ import * as sinon from 'sinon';
interface TestContext extends TestContextBase {
onDataReady: () => void;
fetchOptions: RequestInit;
exampleData?: Record<string, unknown>;
}

const NOOP = (): void => {};
Expand Down Expand Up @@ -44,6 +46,20 @@ module('Integration | Component | lottie', function (hooks) {
assert.verifySteps(['data ready called']);
});

test('it renders when using @animationData', async function (this: TestContext, assert) {
this.onDataReady = (): void => assert.step('data ready called');
this.exampleData = exampleData;

await render<TestContext>(hbs`
<Lottie
@animationData={{this.exampleData}}
@onDataReady={{this.onDataReady}}
/>
`);
find('svg');
assert.verifySteps(['data ready called']);
});

test('it calls window.matchMedia to check for prefers-reduced-motion', async function (this: TestContext, assert) {
window.matchMedia = (mediaQuery): MediaQueryList => {
assert.step(`matchMedia(${mediaQuery})`);
Expand Down

0 comments on commit 1c63810

Please sign in to comment.