F95API/test/classes/prefix-parser.ts

43 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2021-03-08 19:57:25 +00:00
"use strict";
// Public module from npm
import { expect } from "chai";
import dotenv from "dotenv";
// 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();
2021-03-10 11:30:35 +00:00
// Test values
const testIDs = [103, 225, 44, 13, 2, 7, 22];
2021-03-15 14:39:26 +00:00
const testPrefixes = ["corruption", "pregnancy", "slave", "VN", "RPGM", "Ren'Py", "Abandoned"];
2021-03-10 11:30:35 +00:00
// Parse values
2021-03-08 19:57:25 +00:00
const ids = parser.prefixesToIDs(testPrefixes);
const tags = parser.idsToPrefixes(ids);
2021-03-10 11:30:35 +00:00
// Assert equality
expect(testPrefixes).to.be.deep.equal(tags, "The tags must be the same");
expect(testIDs).to.be.deep.equal(ids, "The IDs must be the same");
2021-03-08 19:57:25 +00:00
});
}