-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const getStore = () => cy.window().its('store') | ||
|
||
describe('player', () => { | ||
beforeEach(() => { | ||
cy.visit('/') | ||
}); | ||
|
||
it('should be render', () => { | ||
cy.get('#player'); | ||
}); | ||
|
||
it('audio', () => { | ||
cy.get('#player audio'); | ||
}); | ||
|
||
it('render song url', () => { | ||
cy | ||
.get('#player .player__title') | ||
.contains('/jezusesajelzoraketa.mp3') | ||
}); | ||
|
||
it('render song duration', () => { | ||
cy | ||
.get('#player .player__duration') | ||
.contains('00:05:46') | ||
}); | ||
|
||
context('without song', () => { | ||
beforeEach(() => { | ||
getStore().then(store => { | ||
store.set({ song: {} }) | ||
}) | ||
}) | ||
|
||
it('default title', () => { | ||
cy | ||
.get('.player__title') | ||
.contains('No sound selected') | ||
}); | ||
|
||
it.skip('default duration', () => { | ||
cy | ||
.get('#player .player__duration') | ||
.contains('--:--:--') | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import * as sapper from '../__sapper__/client.js'; | ||
import { Store } from 'svelte/store.js'; | ||
|
||
|
||
sapper.start({ | ||
target: document.querySelector('#tilos-client') | ||
target: document.querySelector('#tilos-client'), | ||
store: data => { | ||
const store = new Store(data); | ||
window.store = store; | ||
return store; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div id="player" class="player"> | ||
<audio src={ $song.url } controls bind:duration=duration></audio> | ||
<h3 class="player__title">{ $song.url ? $song.url : 'No sound selected' }</h3> | ||
<div class="player__duration">{ format(duration) }</div> | ||
</div> | ||
|
||
|
||
<script> | ||
const pad = num => num < 10 ? '0' + num : num; | ||
export default { | ||
helpers: { | ||
format: time => { | ||
if (isNaN(time)) return '--:--:--'; | ||
const hours = Math.floor(time / (60 * 60)) | ||
const minutes = Math.floor((time / 60) % 60); | ||
const seconds = Math.ceil((time % 60)); | ||
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`; | ||
} | ||
}, | ||
data() { | ||
return { duration: 0 } | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.