From a9fb7231e6c2c235edfdc0451bd2c20ffcb46ad3 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Mon, 8 Mar 2021 20:57:25 +0100 Subject: [PATCH] Translate in typescript --- test/classes/prefix-parser.ts | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/classes/prefix-parser.ts diff --git a/test/classes/prefix-parser.ts b/test/classes/prefix-parser.ts new file mode 100644 index 0000000..dfb7708 --- /dev/null +++ b/test/classes/prefix-parser.ts @@ -0,0 +1,48 @@ +"use strict"; + +// Public module from npm +import { expect } from "chai"; +import dotenv from "dotenv"; +import { isEqual } from "lodash"; + +// Modules from file +import { login, PrefixParser } from "../../src/index"; + +// Configure the .env reader +dotenv.config(); + +// Global variables +const USERNAME = process.env.F95_USERNAME; +const PASSWORD = process.env.F95_PASSWORD; + +export function suite(): void { + //#region Setup + + before(async function beforeAll() { + await login(USERNAME, PASSWORD); + }); + + //#endregion Setup + + it("Parse prefixes", async function testPrefixParser() { + // Create a new parser + const parser = new PrefixParser(); + + const testPrefixes = [ + "corruption", + "pregnancy", + "slave", + "VN", + "RPGM", + "Ren'Py", + "Abandoned" + ]; + const ids = parser.prefixesToIDs(testPrefixes); + const tags = parser.idsToPrefixes(ids); + + const tagsEquality = isEqual(testPrefixes, tags); + expect(tagsEquality, "The tags must be the same").to.be.true; + const idsEquality = isEqual([103, 225, 44, 13, 2, 7, 22], ids); + expect(idsEquality, "The IDs must be the same").to.be.true; + }); +}