Fixed messageEmbed test, added parseVars lib test.
This commit is contained in:
parent
2465bb6324
commit
da62401f59
|
@ -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(
|
||||
|
|
|
@ -1,55 +1,49 @@
|
|||
jest.useFakeTimers();
|
||||
import {strict as assert} from "assert";
|
||||
//import {extractFirstMessageLink} from "./messageEmbed";
|
||||
import {extractFirstMessageLink} from "./messageEmbed";
|
||||
|
||||
/*describe("modules/messageEmbed", () => {
|
||||
describe("modules/messageEmbed", () => {
|
||||
describe("extractFirstMessageLink()", () => {
|
||||
const guildID = "802906483866631183";
|
||||
const channelID = "681747101169682147"
|
||||
const channelID = "681747101169682147";
|
||||
const messageID = "996363055050949479";
|
||||
const post = `channels/${guildID}/${channelID}/${messageID}`;
|
||||
const commonUrl = `https://discord.com/channels/${post}`;
|
||||
const commonUrl = `https://discord.com/${post}`;
|
||||
const combined = [guildID, channelID, messageID];
|
||||
|
||||
it('should return work and extract correctly on an isolated link', () => {
|
||||
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', () => {
|
||||
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 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', () => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue