diff options
| author | caleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu> | 2022-03-23 17:36:01 -0400 |
|---|---|---|
| committer | caleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu> | 2022-03-23 17:36:01 -0400 |
| commit | e28fcc59a76772eae64ed480919cddb60a3b5fce (patch) | |
| tree | db7ed6cf18f928fae734f3cc9430bb2b220ba2a0 /webAO/components | |
| parent | a7facd6e825e3a2d60752df0b8526482b19a12de (diff) | |
| parent | ffa23343e0a0badd9e50a005359fdb79efead995 (diff) | |
Merge branch 'master' of https://github.com/AttorneyOnline/webAO into multipleBackgroundTypes
Diffstat (limited to 'webAO/components')
| -rw-r--r-- | webAO/components/__tests__/audioChannels.test.js | 9 | ||||
| -rw-r--r-- | webAO/components/__tests__/blips.test.js | 9 | ||||
| -rw-r--r-- | webAO/components/audioChannels.js | 13 | ||||
| -rw-r--r-- | webAO/components/blip.js | 17 |
4 files changed, 48 insertions, 0 deletions
diff --git a/webAO/components/__tests__/audioChannels.test.js b/webAO/components/__tests__/audioChannels.test.js new file mode 100644 index 0000000..243d870 --- /dev/null +++ b/webAO/components/__tests__/audioChannels.test.js @@ -0,0 +1,9 @@ +import createAudioChannels from "../audioChannels"; + +describe('createAudioChannels', () => { + test('Should create 4 channels', () => { + document.body.innerHTML = '' + createAudioChannels(4) + expect(document.getElementsByClassName('audioChannel').length).toBe(4) + }) +})
\ No newline at end of file diff --git a/webAO/components/__tests__/blips.test.js b/webAO/components/__tests__/blips.test.js new file mode 100644 index 0000000..9c57e78 --- /dev/null +++ b/webAO/components/__tests__/blips.test.js @@ -0,0 +1,9 @@ +import createBlip from "../blip"; + +describe('createBlip', () => { + test('create 3 blips audios', () => { + document.body.innerHTML = `` + createBlip(3) + expect(document.getElementsByClassName('blipSound').length).toBe(3) + }) +})
\ No newline at end of file diff --git a/webAO/components/audioChannels.js b/webAO/components/audioChannels.js new file mode 100644 index 0000000..1979653 --- /dev/null +++ b/webAO/components/audioChannels.js @@ -0,0 +1,13 @@ +/** + * + * @param {number} amountOfChannels Amount of Blips to put on page + */ +const createAudioChannels = (amountOfChannels) => { + for (let i = 0; i < amountOfChannels; i++) { + const audioChannel = document.createElement('audio') + audioChannel.setAttribute('class', 'audioChannel') + document.body.appendChild(audioChannel) + } +} +createAudioChannels(4) +export default createAudioChannels diff --git a/webAO/components/blip.js b/webAO/components/blip.js new file mode 100644 index 0000000..eacbeaf --- /dev/null +++ b/webAO/components/blip.js @@ -0,0 +1,17 @@ +import AO_HOST from '../client/aoHost' + +/** + * + * @param {number} amountOfBlips Amount of Blips to put on page + */ +const createBlip = (amountOfBlips) => { + for (let i = 0; i < amountOfBlips; i++) { + const audio = document.createElement('audio') + const blipUrl = `${AO_HOST}sounds/general/sfx-blipmale.opus` + audio.setAttribute('class', 'blipSound') + audio.setAttribute('src', blipUrl) + document.body.appendChild(audio) + } +} +createBlip(6) +export default createBlip
\ No newline at end of file |
