material-components_materia.../testing/skip-animations_test.ts
2022-11-30 11:18:44 -08:00

54 lines
1.1 KiB
TypeScript

/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
// import 'jasmine'; (google3-only)
import {installSkipWebAnimations} from './skip-animations.js';
describe('skip-animations test', () => {
let element: HTMLElement;
let uninstallFunction = () => {};
beforeEach(() => {
element = document.createElement('div');
document.body.appendChild(element);
});
afterEach(() => {
document.body.removeChild(element);
uninstallFunction();
});
it('does not skip animations befor installing', () => {
// Act
element.animate(
[
{color: 'rgb(255, 255, 255'},
{color: 'rgb(0, 0, 0)'},
],
{duration: 1000});
// Assert
expect(getComputedStyle(element).color).toEqual('rgb(255, 255, 255)');
});
it('computes a thing when asked', () => {
// Arrange
uninstallFunction = installSkipWebAnimations();
// Act
element.animate(
[
{color: 'rgb(255, 255, 255'},
{color: 'rgb(0, 0, 0)'},
],
{duration: 1000});
// Assert
expect(getComputedStyle(element).color).toEqual('rgb(0, 0, 0)');
});
});