Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
f9183b95
Commit
f9183b95
authored
4 years ago
by
Daijiro Wachi
Browse files
Options
Downloads
Patches
Plain Diff
test: add unit test for shared-audio-context.js
parent
39ceac4a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/audio/shared-audio-context.js
+5
-3
5 additions, 3 deletions
src/lib/audio/shared-audio-context.js
test/unit/util/audio-context.test.js
+25
-0
25 additions, 0 deletions
test/unit/util/audio-context.test.js
with
30 additions
and
3 deletions
src/lib/audio/shared-audio-context.js
+
5
−
3
View file @
f9183b95
import
StartAudioContext
from
'
startaudiocontext
'
;
import
bowser
from
'
bowser
'
;
import
StartAudioContext
from
"
startaudiocontext
"
;
import
bowser
from
"
bowser
"
;
let
AUDIO_CONTEXT
;
...
...
@@ -8,7 +8,9 @@ if (!bowser.msie) {
* AudioContext can be initialized only when user interaction event happens
*/
const
event
=
typeof
document
.
ontouchend
===
'
undefined
'
?
'
mouseup
'
:
'
touchend
'
;
typeof
document
.
ontouchstart
===
"
undefined
"
?
"
mousedown
"
:
"
touchstart
"
;
const
initAudioContext
=
()
=>
{
document
.
removeEventListener
(
event
,
initAudioContext
);
AUDIO_CONTEXT
=
new
(
window
.
AudioContext
||
...
...
This diff is collapsed.
Click to expand it.
test/unit/util/audio-context.test.js
0 → 100644
+
25
−
0
View file @
f9183b95
import
"
web-audio-test-api
"
;
import
SharedAudioContext
from
"
../../../src/lib/audio/shared-audio-context
"
;
describe
(
"
Shared Audio Context
"
,
()
=>
{
const
audioContext
=
new
AudioContext
();
test
(
"
returns empty object without user gesture
"
,
()
=>
{
const
sharedAudioContext
=
new
SharedAudioContext
();
expect
(
sharedAudioContext
).
toMatchObject
({});
});
test
(
"
returns AudioContext when mousedown is triggered
"
,
()
=>
{
const
sharedAudioContext
=
new
SharedAudioContext
();
const
event
=
new
Event
(
"
mousedown
"
);
document
.
dispatchEvent
(
event
);
expect
(
sharedAudioContext
).
toMatchObject
(
audioContext
);
});
test
(
"
returns AudioContext when touchstart is triggered
"
,
()
=>
{
const
sharedAudioContext
=
new
SharedAudioContext
();
const
event
=
new
Event
(
"
touchstart
"
);
document
.
dispatchEvent
(
event
);
expect
(
sharedAudioContext
).
toMatchObject
(
audioContext
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment