Skip to content

Commit

Permalink
fix: end test waiter when using @AnimationData arg
Browse files Browse the repository at this point in the history
test(test-app): add @AnimationData render smoke test
  • Loading branch information
22a committed Apr 12, 2024
1 parent 144518e commit ba1cb89
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions ember-lottie/src/components/lottie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class LottieComponent extends Component<LottieSignature> {

if (this.args.animationData) {
animationData = this.args.animationData;
waiter.endAsync(token);
} else if (this.args.path) {
try {
const response = await (this.args.fetchOptions
Expand Down
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 ba1cb89

Please sign in to comment.