Skip to content

Commit

Permalink
end test waiter when using @AnimationData arg
Browse files Browse the repository at this point in the history
Co-authored-by: boris.petrenko <[email protected]>
  • Loading branch information
22a and oreqizer committed Apr 15, 2024
1 parent 144518e commit 6c72d61
Show file tree
Hide file tree
Showing 4 changed files with 23 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/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try

# fixtures
tests/**/fixtures/
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 6c72d61

Please sign in to comment.