mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
8 years ago
|
export default {
|
||
8 years ago
|
// not sure if we can really test this in JSDOM. Refer to
|
||
|
// https://svelte.technology/repl?example=media-elements
|
||
|
// instead
|
||
|
skip: true,
|
||
|
|
||
8 years ago
|
test ( assert, component, target, window ) {
|
||
|
assert.equal( component.get( 't' ), 0 );
|
||
|
assert.equal( component.get( 'd' ), 0 );
|
||
7 years ago
|
assert.equal( component.get( 'v' ), 0.5 );
|
||
8 years ago
|
assert.equal( component.get( 'paused' ), true );
|
||
|
|
||
|
const audio = target.querySelector( 'audio' );
|
||
|
const timeupdate = new window.Event( 'timeupdate' );
|
||
|
const durationchange = new window.Event( 'durationchange' );
|
||
7 years ago
|
const volumechange = new window.Event( 'volumechange' );
|
||
8 years ago
|
|
||
|
audio.currentTime = 10;
|
||
|
audio.duration = 20;
|
||
7 years ago
|
audio.volume = 0.75;
|
||
8 years ago
|
audio.dispatchEvent( timeupdate );
|
||
|
audio.dispatchEvent( durationchange );
|
||
7 years ago
|
audio.dispatchEvent( volumechange );
|
||
8 years ago
|
audio.play();
|
||
|
|
||
|
assert.equal( component.get( 't' ), 10 );
|
||
|
assert.equal( component.get( 'd' ), 0 ); // not 20, because read-only. Not sure how to test this!
|
||
7 years ago
|
assert.equal( component.get( 'v' ), 0.75 );
|
||
8 years ago
|
assert.equal( component.get( 'paused' ), true ); // ditto...
|
||
|
component.destroy();
|
||
|
}
|
||
|
};
|