Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
stonedDiscord authored and actions-user committed Nov 20, 2024
1 parent 376fadc commit b8283b3
Show file tree
Hide file tree
Showing 28 changed files with 1,239 additions and 762 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module.exports = {
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',
coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'babel',
coverageProvider: "babel",

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: 'jsdom',
testEnvironment: "jsdom",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand Down
44 changes: 22 additions & 22 deletions webAO/__tests__/iniParse.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import iniParse from '../iniParse';
import iniParse from "../iniParse";

const iniExample = `
[Options]
Expand All @@ -9,31 +9,31 @@ showname = Matty
number = 9
1 = Normal#-#normal#0#1
`;
describe('iniParse', () => {
test('should not lowercase value if key is showname', () => {
const parsedIni = iniParse(`
describe("iniParse", () => {
test("should not lowercase value if key is showname", () => {
const parsedIni = iniParse(`
[test]
showname = MATT
`);
expect(parsedIni.test.showname).toBe('MATT');
});
test('should lowercase value if key is not showname', () => {
const parsedIni = iniParse(`
expect(parsedIni.test.showname).toBe("MATT");
});
test("should lowercase value if key is not showname", () => {
const parsedIni = iniParse(`
[test]
party = TIME
`);
expect(parsedIni.test.party).toBe('time');
});
test('should parse sections', () => {
const parsedIni = iniParse(iniExample);
expect(Object.keys(parsedIni).length).toBe(2);
});
test('should parse parameters', () => {
const parsedIni = iniParse(iniExample);
expect(Object.keys(parsedIni.options).length).toBe(2);
});
test('should remove empty lines', () => {
const parsedIni = iniParse(`
expect(parsedIni.test.party).toBe("time");
});
test("should parse sections", () => {
const parsedIni = iniParse(iniExample);
expect(Object.keys(parsedIni).length).toBe(2);
});
test("should parse parameters", () => {
const parsedIni = iniParse(iniExample);
expect(Object.keys(parsedIni.options).length).toBe(2);
});
test("should remove empty lines", () => {
const parsedIni = iniParse(`
[test]
Expand All @@ -42,6 +42,6 @@ describe('iniParse', () => {
`);
expect(Object.keys(parsedIni.test).length).toBe(2);
});
expect(Object.keys(parsedIni.test).length).toBe(2);
});
});
180 changes: 104 additions & 76 deletions webAO/client/__tests__/setEmote.test.js
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);
});
});
14 changes: 7 additions & 7 deletions webAO/components/__tests__/audioChannels.test.js
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);
});
});
14 changes: 7 additions & 7 deletions webAO/components/__tests__/blips.test.js
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);
});
});
10 changes: 5 additions & 5 deletions webAO/components/audioChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* @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);
}
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;
16 changes: 8 additions & 8 deletions webAO/components/blip.js
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;
Loading

0 comments on commit b8283b3

Please sign in to comment.