From 1899c8058fde577318c1911a35108ea8d91cd1a7 Mon Sep 17 00:00:00 2001 From: "caleb.mabry.15@cnu.edu" Date: Thu, 17 Mar 2022 20:00:07 -0400 Subject: Adding blip sounds to actual audio tags --- webAO/components/__tests__/blips.test.js | 9 +++++++++ webAO/components/blip.js | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 webAO/components/__tests__/blips.test.js create mode 100644 webAO/components/blip.js (limited to 'webAO/components') 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/blip.js b/webAO/components/blip.js new file mode 100644 index 0000000..409b907 --- /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(3) +export default createBlip \ No newline at end of file -- cgit