aboutsummaryrefslogtreecommitdiff
path: root/webAO/client
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-03-25 18:32:52 +0100
committerGitHub <noreply@github.com>2022-03-25 18:32:52 +0100
commitd1472f152c8ca9de8d790f9cc88e79d1e3b11be6 (patch)
tree821b8c77722692e60c502ede90664f1b75fde1fc /webAO/client
parente4d1e1cd4b361e96aad09d9b5539db44cb1ed8dd (diff)
parent8406b6f1fb6ce6e61dab3e39f1a5751c49e6d184 (diff)
Merge pull request #130 from AttorneyOnline/multipleBackgroundTypes
Multiple Background Types
Diffstat (limited to 'webAO/client')
-rw-r--r--webAO/client/__tests__/setEmote.test.js50
-rw-r--r--webAO/client/setEmote.js6
2 files changed, 28 insertions, 28 deletions
diff --git a/webAO/client/__tests__/setEmote.test.js b/webAO/client/__tests__/setEmote.test.js
index d81c2cc..1db13c9 100644
--- a/webAO/client/__tests__/setEmote.test.js
+++ b/webAO/client/__tests__/setEmote.test.js
@@ -1,10 +1,10 @@
import setEmote from '../setEmote';
import Client from '../../client';
-import fileExistsSync from '../../utils/fileExistsSync';
+import fileExists from '../../utils/fileExists';
import transparentPng from '../../constants/transparentPng';
jest.mock('../../client');
-jest.mock('../../utils/fileExistsSync');
+jest.mock('../../utils/fileExists');
describe('setEmote', () => {
const AO_HOST = '';
@@ -17,98 +17,98 @@ describe('setEmote', () => {
const client = new Client('127.0.0.1');
const firstExtension = '.gif';
- test('Should have a client_def_char_img with a valid source', () => {
- fileExistsSync.mockReturnValue(true);
+ 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" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'def');
+ 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', () => {
+ test('Should have a client_pro_char_img to have a valid src', async () => {
document.body.innerHTML = `
<img id="client_pro_char_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'pro');
+ 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', () => {
+ test('Should have a client_wit_char_img', async () => {
document.body.innerHTML = `
<img id="client_wit_char_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'wit');
+ 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', () => {
+ test('Should have a client_def_pair_img', async () => {
document.body.innerHTML = `
<img id="client_def_pair_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'def');
+ 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', () => {
+ test('Should have a client_pro_pair_img', async () => {
document.body.innerHTML = `
<img id="client_pro_pair_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'pro');
+ 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', () => {
+ test('Should have a client_wit_pair_img', async () => {
document.body.innerHTML = `
<img id="client_wit_pair_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'wit');
+ 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', () => {
+ test('Should have a client_char_img', async () => {
document.body.innerHTML = `
<img id="client_char_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'notvalid');
+ 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', () => {
+ test('Should have a client_pair_img', async () => {
document.body.innerHTML = `
<img id="client_pair_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'notvalid');
+ 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', () => {
- fileExistsSync.mockReturnValueOnce(false);
+ test('Should handle .png urls differently', async () => {
+ fileExists.mockReturnValueOnce(false);
document.body.innerHTML = `
<img id="client_pair_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
+ 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', () => {
- fileExistsSync.mockReturnValue(false);
+ test('Should replace character if new character responds', async () => {
+ fileExists.mockReturnValue(false);
document.body.innerHTML = `
<img id="client_pair_img" />
`;
- setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
+ await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
const expected = transparentPng;
expect(document.getElementById('client_pair_img').src).toEqual(expected);
});
diff --git a/webAO/client/setEmote.js b/webAO/client/setEmote.js
index 4bbaab7..f682fe5 100644
--- a/webAO/client/setEmote.js
+++ b/webAO/client/setEmote.js
@@ -1,12 +1,12 @@
import transparentPng from '../constants/transparentPng';
-import fileExistsSync from '../utils/fileExistsSync';
+import fileExists from '../utils/fileExists';
/**
* Sets all the img tags to the right sources
* @param {*} chatmsg
*/
-const setEmote = (AO_HOST, client, charactername, emotename, prefix, pair, side) => {
+const setEmote = async (AO_HOST, client, charactername, emotename, prefix, pair, side) => {
const pairID = pair ? 'pair' : 'char';
const characterFolder = `${AO_HOST}characters/`;
const acceptedPositions = ['def', 'pro', 'wit'];
@@ -30,7 +30,7 @@ const setEmote = (AO_HOST, client, charactername, emotename, prefix, pair, side)
} else {
url = `${characterFolder}${encodeURI(charactername)}/${encodeURI(prefix)}${encodeURI(emotename)}${extension}`;
}
- const exists = fileExistsSync(url);
+ const exists = await fileExists(url);
if (exists) {
emoteSelector.src = url;
break;