mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
56 lines
1016 B
TypeScript
56 lines
1016 B
TypeScript
import {render} from '@testing-library/react';
|
|
import {render as amisRender} from '../../src';
|
|
import {makeEnv} from '../helper';
|
|
|
|
let times = 0;
|
|
|
|
beforeAll(() => {
|
|
// jsdom not implemented: HTMLMediaElement.prototype.load
|
|
// here: https://github.com/jsdom/jsdom/issues/1515
|
|
Object.defineProperty(global.window.HTMLMediaElement.prototype, 'load', {
|
|
get() {
|
|
return () => {
|
|
times++;
|
|
};
|
|
}
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
times = 0;
|
|
});
|
|
|
|
test('Renderer:audio', () => {
|
|
const {container} = render(
|
|
amisRender(
|
|
{
|
|
type: 'audio',
|
|
src: '${url}'
|
|
},
|
|
{
|
|
data: {
|
|
url: 'https://example.com/music.mp3'
|
|
}
|
|
},
|
|
makeEnv({})
|
|
)
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
test('should not call load method at first render phase', () => {
|
|
render(
|
|
amisRender(
|
|
{
|
|
type: 'audio',
|
|
src: 'https://example.com/music.mp3'
|
|
},
|
|
{},
|
|
makeEnv({})
|
|
)
|
|
);
|
|
|
|
expect(times).toBe(0);
|
|
});
|