Fixed messageEmbed test, added parseVars lib test.

This commit is contained in:
Keanu Timmermans 2021-04-09 17:17:25 +02:00
parent 2465bb6324
commit da62401f59
Signed by: keanucode
GPG Key ID: A7431C0D513CA93B
3 changed files with 44 additions and 44 deletions

0
.husky/pre-commit Normal file → Executable file
View File

View File

@ -1,5 +1,5 @@
import {strict as assert} from "assert";
import {pluralise, pluraliseSigned, replaceAll, toTitleCase, split} from "./lib";
import {pluralise, pluraliseSigned, replaceAll, toTitleCase, split, parseVars} from "./lib";
// I can't figure out a way to run the test suite while running the bot.
describe("Wrappers", () => {
@ -52,6 +52,12 @@ describe("Wrappers", () => {
});
});
describe("#parseVars()", () => {
it('should replace %test% with "yeet"', () => {
assert.strictEqual(parseVars("ya %test%", {test: "yeet"}), "ya yeet");
});
});
describe("#toTitleCase()", () => {
it("should capitalize the first letter of each word", () => {
assert.strictEqual(

View File

@ -1,55 +1,49 @@
jest.useFakeTimers();
import {strict as assert} from "assert";
//import {extractFirstMessageLink} from "./messageEmbed";
import {extractFirstMessageLink} from "./messageEmbed";
/*describe("modules/messageEmbed", () => {
describe("extractFirstMessageLink()", () => {
const guildID = "802906483866631183";
const channelID = "681747101169682147"
const messageID = "996363055050949479";
const post = `channels/${guildID}/${channelID}/${messageID}`;
const commonUrl = `https://discord.com/channels/${post}`;
const combined = [guildID, channelID, messageID];
describe("modules/messageEmbed", () => {
describe("extractFirstMessageLink()", () => {
const guildID = "802906483866631183";
const channelID = "681747101169682147";
const messageID = "996363055050949479";
const post = `channels/${guildID}/${channelID}/${messageID}`;
const commonUrl = `https://discord.com/${post}`;
const combined = [guildID, channelID, messageID];
it('should return work and extract correctly on an isolated link', () => {
const result = extractFirstMessageLink(commonUrl);
assert.deepStrictEqual(result, combined);
})
it("should return work and extract correctly on an isolated link", () => {
const result = extractFirstMessageLink(commonUrl);
assert.deepStrictEqual(result, combined);
});
it('should return work and extract correctly on a link within a message', () => {
const result = extractFirstMessageLink(`sample text${commonUrl}, more sample text`);
assert.deepStrictEqual(result, combined);
})
it("should return work and extract correctly on a link within a message", () => {
const result = extractFirstMessageLink(`sample text${commonUrl}, more sample text`);
assert.deepStrictEqual(result, combined);
});
it('should return null on "!link"', () => {
const result = extractFirstMessageLink(`just some !${commonUrl} text`);
assert.strictEqual(result, null);
})
it('should return null on "!link"', () => {
const result = extractFirstMessageLink(`just some !${commonUrl} text`);
assert.strictEqual(result, null);
});
it('should return null on "<link>"', () => {
const result = extractFirstMessageLink(`just some <${commonUrl}> text`);
assert.strictEqual(result, null);
})
it('should return null on "<link>"', () => {
const result = extractFirstMessageLink(`just some <${commonUrl}> text`);
assert.strictEqual(result, null);
});
it('should return work and extract correctly on "<link"', () => {
const result = extractFirstMessageLink(`just some <${commonUrl} text`);
assert.deepStrictEqual(result, combined);
})
it('should return work and extract correctly on "<link"', () => {
const result = extractFirstMessageLink(`just some <${commonUrl} text`);
assert.deepStrictEqual(result, combined);
});
it('should return work and extract correctly on "link>"', () => {
const result = extractFirstMessageLink(`just some ${commonUrl}> text`);
assert.deepStrictEqual(result, combined);
})
it('should return work and extract correctly on "link>"', () => {
const result = extractFirstMessageLink(`just some ${commonUrl}> text`);
assert.deepStrictEqual(result, combined);
});
it('should return work and extract correctly on a canary link', () => {
const result = extractFirstMessageLink(`https://canary.discord.com/${post}`);
assert.deepStrictEqual(result, combined);
})
})
});*/
describe("placeholder", () => {
it("placeholder", async () => {
assert.strictEqual(1, 1);
it("should return work and extract correctly on a canary link", () => {
const result = extractFirstMessageLink(`https://canary.discord.com/${post}`);
assert.deepStrictEqual(result, combined);
});
});
});