-
Notifications
You must be signed in to change notification settings - Fork 13
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
1 parent
376fadc
commit b8283b3
Showing
28 changed files
with
1,239 additions
and
762 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,140 @@ | ||
import setEmote from '../setEmote.ts'; | ||
import Client from '../../client.ts'; | ||
import fileExists from '../../utils/fileExists'; | ||
import transparentPng from '../../constants/transparentPng'; | ||
import setEmote from "../setEmote.ts"; | ||
import Client from "../../client.ts"; | ||
import fileExists from "../../utils/fileExists"; | ||
import transparentPng from "../../constants/transparentPng"; | ||
|
||
jest.mock('../../viewport/utils/createMusic'); | ||
jest.mock('../../utils/fileExists'); | ||
jest.mock('../../viewport/utils/createSfxAudio'); | ||
jest.mock('../../viewport/utils/createShoutAudio'); | ||
jest.mock('../../viewport/utils/createTestimonyAudio'); | ||
describe('setEmote', () => { | ||
const AO_HOST = ''; | ||
jest.mock("../../viewport/utils/createMusic"); | ||
jest.mock("../../utils/fileExists"); | ||
jest.mock("../../viewport/utils/createSfxAudio"); | ||
jest.mock("../../viewport/utils/createShoutAudio"); | ||
jest.mock("../../viewport/utils/createTestimonyAudio"); | ||
describe("setEmote", () => { | ||
const AO_HOST = ""; | ||
|
||
const client = new Client('127.0.0.1'); | ||
const firstExtension = '.gif'; | ||
const client = new Client("127.0.0.1"); | ||
const firstExtension = ".gif"; | ||
|
||
test('Should have a client_def_char_img with a valid source', async () => { | ||
fileExists.mockReturnValue(true); | ||
document.body.innerHTML = ` | ||
test("Should have a client_def_char_img with a valid source", async () => { | ||
fileExists.mockReturnValue(true); | ||
document.body.innerHTML = ` | ||
<img id="client_def_char_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'def'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
expect(document.getElementById('client_def_char_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_pro_char_img to have a valid src', async () => { | ||
document.body.innerHTML = ` | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 0, "def"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
expect(document.getElementById("client_def_char_img").src).toEqual( | ||
expected, | ||
); | ||
}); | ||
test("Should have a client_pro_char_img to have a valid src", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_pro_char_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'pro'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
expect(document.getElementById('client_pro_char_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_wit_char_img', async () => { | ||
document.body.innerHTML = ` | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 0, "pro"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
expect(document.getElementById("client_pro_char_img").src).toEqual( | ||
expected, | ||
); | ||
}); | ||
test("Should have a client_wit_char_img", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_wit_char_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'wit'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 0, "wit"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
|
||
expect(document.getElementById('client_wit_char_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_def_pair_img', async () => { | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_wit_char_img").src).toEqual( | ||
expected, | ||
); | ||
}); | ||
test("Should have a client_def_pair_img", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_def_pair_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'def'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 1, "def"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
|
||
expect(document.getElementById('client_def_pair_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_pro_pair_img', async () => { | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_def_pair_img").src).toEqual( | ||
expected, | ||
); | ||
}); | ||
test("Should have a client_pro_pair_img", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_pro_pair_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'pro'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 1, "pro"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
|
||
expect(document.getElementById('client_pro_pair_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_wit_pair_img', async () => { | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_pro_pair_img").src).toEqual( | ||
expected, | ||
); | ||
}); | ||
test("Should have a client_wit_pair_img", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_wit_pair_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'wit'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 1, "wit"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
|
||
expect(document.getElementById('client_wit_pair_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_char_img', async () => { | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_wit_pair_img").src).toEqual( | ||
expected, | ||
); | ||
}); | ||
test("Should have a client_char_img", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_char_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'notvalid'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 0, "notvalid"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
|
||
expect(document.getElementById('client_char_img').src).toEqual(expected); | ||
}); | ||
test('Should have a client_pair_img', async () => { | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_char_img").src).toEqual(expected); | ||
}); | ||
test("Should have a client_pair_img", async () => { | ||
document.body.innerHTML = ` | ||
<img id="client_pair_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'notvalid'); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
await setEmote(AO_HOST, client, "salanto", "coding", "(a)", 1, "notvalid"); | ||
const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`; | ||
|
||
expect(document.getElementById('client_pair_img').src).toEqual(expected); | ||
}); | ||
test('Should handle .png urls differently', async () => { | ||
fileExists.mockReturnValueOnce(false); | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_pair_img").src).toEqual(expected); | ||
}); | ||
test("Should handle .png urls differently", async () => { | ||
fileExists.mockReturnValueOnce(false); | ||
document.body.innerHTML = ` | ||
<img id="client_pair_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid'); | ||
const expected = 'http://localhost/characters/salanto/coding.png'; | ||
await setEmote( | ||
AO_HOST, | ||
client, | ||
"salanto", | ||
"coding", | ||
"prefixNotValid", | ||
1, | ||
"notvalid", | ||
); | ||
const expected = "http://localhost/characters/salanto/coding.png"; | ||
|
||
expect(document.getElementById('client_pair_img').src).toEqual(expected); | ||
}); | ||
test('Should replace character if new character responds', async () => { | ||
fileExists.mockReturnValue(false); | ||
document.body.innerHTML = ` | ||
expect(document.getElementById("client_pair_img").src).toEqual(expected); | ||
}); | ||
test("Should replace character if new character responds", async () => { | ||
fileExists.mockReturnValue(false); | ||
document.body.innerHTML = ` | ||
<img id="client_pair_img" /> | ||
`; | ||
await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid'); | ||
const expected = transparentPng; | ||
expect(document.getElementById('client_pair_img').src).toEqual(expected); | ||
}); | ||
await setEmote( | ||
AO_HOST, | ||
client, | ||
"salanto", | ||
"coding", | ||
"prefixNotValid", | ||
1, | ||
"notvalid", | ||
); | ||
const expected = transparentPng; | ||
expect(document.getElementById("client_pair_img").src).toEqual(expected); | ||
}); | ||
}); |
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,9 +1,9 @@ | ||
import createAudioChannels from '../audioChannels'; | ||
import createAudioChannels from "../audioChannels"; | ||
|
||
describe('createAudioChannels', () => { | ||
test('Should create 4 channels', () => { | ||
document.body.innerHTML = ''; | ||
createAudioChannels(4); | ||
expect(document.getElementsByClassName('audioChannel').length).toBe(4); | ||
}); | ||
describe("createAudioChannels", () => { | ||
test("Should create 4 channels", () => { | ||
document.body.innerHTML = ""; | ||
createAudioChannels(4); | ||
expect(document.getElementsByClassName("audioChannel").length).toBe(4); | ||
}); | ||
}); |
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,9 +1,9 @@ | ||
import createBlip from '../blip'; | ||
import createBlip from "../blip"; | ||
|
||
describe('createBlip', () => { | ||
test('create 3 blips audios', () => { | ||
document.body.innerHTML = ''; | ||
createBlip(3); | ||
expect(document.getElementsByClassName('blipSound').length).toBe(3); | ||
}); | ||
describe("createBlip", () => { | ||
test("create 3 blips audios", () => { | ||
document.body.innerHTML = ""; | ||
createBlip(3); | ||
expect(document.getElementsByClassName("blipSound").length).toBe(3); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { AO_HOST } from '../client/aoHost.ts'; | ||
import { AO_HOST } from "../client/aoHost.ts"; | ||
|
||
/** | ||
* | ||
* @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/blips/male.opus`; | ||
audio.setAttribute('class', 'blipSound'); | ||
audio.setAttribute('src', blipUrl); | ||
document.body.appendChild(audio); | ||
} | ||
for (let i = 0; i < amountOfBlips; i++) { | ||
const audio = document.createElement("audio"); | ||
const blipUrl = `${AO_HOST}sounds/blips/male.opus`; | ||
audio.setAttribute("class", "blipSound"); | ||
audio.setAttribute("src", blipUrl); | ||
document.body.appendChild(audio); | ||
} | ||
}; | ||
createBlip(6); | ||
export default createBlip; |
Oops, something went wrong.