From 50d868d96d3b3ab60cdff9c18b9533dcfe839b14 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Thu, 3 Dec 2020 12:38:46 +0100 Subject: [PATCH] Added tests for PrefixParser --- package.json | 2 +- test/index-test.js | 4 ++-- ...g-parser-test.js => prefix-parser-test.js} | 20 ++++++++----------- 3 files changed, 11 insertions(+), 15 deletions(-) rename test/suites/{tag-parser-test.js => prefix-parser-test.js} (60%) diff --git a/package.json b/package.json index f76260a..a001027 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "user data" ], "scripts": { - "unit-test-mocha": "nyc --reporter=text mocha './test/index-test.js'", + "test": "nyc --reporter=text mocha './test/index-test.js'", "report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov -t 38ad72bf-a29d-4c2e-9827-96cbe037afd2", "run-example": "node ./app/example.js", "publish": "npm publish" diff --git a/test/index-test.js b/test/index-test.js index 89e4d12..0fab844 100644 --- a/test/index-test.js +++ b/test/index-test.js @@ -7,7 +7,7 @@ const network = require("./suites/network-helper-test.js").suite; const scraper = require("./suites/scraper-test.js").suite; const searcher = require("./suites/searcher-test.js").suite; const uScraper = require("./suites/user-scraper-test.js").suite; -const tags = require("./suites/tag-parser-test.js").suite; +const prefixParser = require("./suites/prefix-parser-test.js").suite; describe("Test basic function", function testBasic() { //#region Set-up @@ -16,7 +16,7 @@ describe("Test basic function", function testBasic() { describe("Test credentials class", credentials.bind(this)); describe("Test network helper", network.bind(this)); - describe("Test tag parser", tags.bind(this)); + describe("Test prefix parser", prefixParser.bind(this)); }); describe("Test F95 modules", function testF95Modules() { diff --git a/test/suites/tag-parser-test.js b/test/suites/prefix-parser-test.js similarity index 60% rename from test/suites/tag-parser-test.js rename to test/suites/prefix-parser-test.js index 5edf426..d3e2327 100644 --- a/test/suites/tag-parser-test.js +++ b/test/suites/prefix-parser-test.js @@ -7,7 +7,7 @@ const { isEqual } = require("lodash"); // Modules from file const Credentials = require("../../app/scripts/classes/credentials.js"); -const TagParser = require("../../app/scripts/classes/tag-parser.js"); +const PrefixParser = require("../../app/scripts/classes/prefix-parser.js"); const { authenticate } = require("../../app/scripts/network-helper.js"); // Configure the .env reader @@ -27,21 +27,17 @@ module.exports.suite = function suite() { }); //#endregion Setup - it("Fetch tags and parse", async function testTagParser() { + it("Parse prefixes", async function testPrefixParser() { // Create a new parser - const tp = new TagParser(); - await tp.fetch(); + const parser = new PrefixParser(); - const dictEquality = isEqual(tp._tagsDict, {}); - expect(dictEquality, "The dictionary should be filled with values").to.be.false; - - const testTags = ["corruption", "pregnancy", "slave"]; - const ids = tp.tagsToIDs(testTags); - const tags = tp.idsToTags(ids); + const testPrefixes = ["corruption", "pregnancy", "slave", "VN", "RPGM", "Ren'Py", "Abandoned"]; + const ids = parser.prefixesToIDs(testPrefixes); + const tags = parser.idsToPrefixes(ids); - const tagsEquality = isEqual(testTags, tags); + const tagsEquality = isEqual(testPrefixes, tags); expect(tagsEquality, "The tags must be the same").to.be.true; - const idsEquality = isEqual([44, 103, 225], ids); + const idsEquality = isEqual([103, 225, 44, 13, 2, 7, 22], ids); expect(idsEquality, "The IDs must be the same").to.be.true; }); }; \ No newline at end of file