material-web/motion/animation_test.ts
Alexander Marks 30c95aeee1 chore: add ".js" extensions to import statements.
In particular, this allows external build tools like Rollup and @web/dev-server to understand imports of Lit, which is configured to require the ".js" extension via its export conditions (so that Lit import maps can remain minimal).

PiperOrigin-RevId: 469772992
2022-08-24 11:01:21 -07:00

58 lines
1.6 KiB
TypeScript

/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import 'jasmine';
import {AnimationSignal, createAnimationSignal} from './animation.js';
describe('createAnimationSignal()', () => {
let task: AnimationSignal;
beforeEach(() => {
task = createAnimationSignal();
});
describe('start()', () => {
it('should return an AbortSignal', () => {
const signal = task.start();
expect(signal).toBeInstanceOf(AbortSignal);
});
it('should abort previous signal on subsequent calls', () => {
const firstSignal = task.start();
expect(firstSignal.aborted)
.withContext('first signal should not be aborted by default')
.toBeFalse();
const secondSignal = task.start();
expect(firstSignal.aborted)
.withContext('first signal should abort after start is called again')
.toBeTrue();
expect(secondSignal.aborted)
.withContext('second signal should not be aborted by default')
.toBeFalse();
});
});
describe('finish()', () => {
it('should not abort the AbortSignal', () => {
const signal = task.start();
task.finish();
expect(signal.aborted)
.withContext('finishing a task should not signal an abort')
.toBeFalse();
});
it('should not abort previous tasks when starting after finishing', () => {
const firstSignal = task.start();
task.finish();
task.start();
expect(firstSignal.aborted)
.withContext('starting a new task should not finished tasks')
.toBeFalse();
});
});
});