commit 6b9e4e5b2b4b94179068a9650ce0fa168728e41c
parent 8708413fdf12475c3cb43131a04c7167c9255521
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Sat, 12 Sep 2020 10:42:30 -0700
Merge pull request #18 from AsherMorgan/create-tests
Create tests.
Diffstat:
6 files changed, 925 insertions(+), 7 deletions(-)
diff --git a/Scripts/Home.js b/Scripts/Home.js
@@ -4,10 +4,7 @@ let quizzerType = null; // Type of quizzer
let app;
-
-// Load the document
-function Load() {
- // Initialize Vue
+function loadVue() {
app = new Vue({
el: "#app", // Mount to app div
@@ -198,6 +195,13 @@ function Load() {
this.darkTheme = null;
},
});
+}
+
+
+
+// Load the document
+function Load() {
+ loadVue();
// Unhide hidden divs
// Divs were hidden to improve interface for users with JS blocked
diff --git a/Scripts/Reference.js b/Scripts/Reference.js
@@ -3,9 +3,8 @@ let app;
-// Load the document
-function Load() {
- // Initialize Vue
+// Initializes the Vue
+function loadVue() {
app = new Vue({
el: "#app", // Mount to app div
@@ -52,6 +51,14 @@ function Load() {
}
}
});
+}
+
+
+
+// Load the document
+function Load() {
+ // Initialize the Vue
+ loadVue();
// Unhide hidden divs
// Divs were hidden to improve interface for users with JS blocked
diff --git a/Tests/index.html b/Tests/index.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Mocha Tests</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css"/>
+ <script src="https://unpkg.com/chai/chai.js"></script>
+ <script src="https://unpkg.com/mocha/mocha.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
+ </head>
+
+ <body>
+ <div id="mocha"></div>
+
+ <!-- Scripts being tested -->
+ <script src="../Scripts/Home.js"></script>
+ <script src="../Scripts/Quizzer.js"></script>
+ <script src="../Scripts/Settings.js"></script>
+
+ <!-- Setup tests -->
+ <script class="mocha-init">
+ mocha.setup('bdd');
+ mocha.checkLeaks();
+ let expect = chai.expect;
+ </script>
+
+ <!-- Tests -->
+ <script src="test.app.js"></script>
+ <script src="test.quizzer.js"></script>
+ <script src="test.settings.js"></script>
+
+ <!-- Run tests -->
+ <script class="mocha-exec">
+ mocha.run();
+ </script>
+ </body>
+</html>
diff --git a/Tests/test.app.js b/Tests/test.app.js
@@ -0,0 +1,410 @@
+describe("App", function() {
+ beforeEach(function() {
+ // Initialize Vue
+ loadVue();
+ });
+
+ describe("Created lifecycle hook", function() {
+ it("State should be 'home'", function() {
+ expect(app.state).to.equal("home");
+ });
+ it("VerFilters should be empty", function() {
+ expect(app.verbFilters.length).to.equal(0);
+ });
+
+ it("VocabFilters should be empty", function() {
+ expect(app.vocabFilters.length).to.equal(0);
+ });
+
+ it("Prompts should be empty", function() {
+ expect(app.vocabFilters.length).to.equal(0);
+ });
+
+ it("PromptIndex should be 0", function() {
+ expect(app.promptIndex).to.equal(0);
+ });
+
+ it("Responce should be empty", function() {
+ expect(app.responce).to.equal("");
+ });
+
+ it("ResponceActive should be true", function() {
+ expect(app.responceActive).to.equal(true);
+ });
+ });
+
+ describe("Back method", function() {
+ it("Should go to home by default", function() {
+ // Set state and test Back method
+ app.state = "home";
+ app.Back();
+ expect(app.state).to.equal("home");
+
+ // Set state and test Back method again
+ app.state = "";
+ app.Back();
+ expect(app.state).to.equal("home");
+
+ // Set state and test Back method again
+ app.state = "test";
+ app.Back();
+ expect(app.state).to.equal("home");
+ });
+
+ it("Should go to home when on settings", function() {
+ // Set state and test Back method
+ app.state = "verbSettings";
+ app.Back();
+ expect(app.state).to.equal("home");
+
+ // Set state and test Back method again
+ app.state = "vocabSettings";
+ app.Back();
+ expect(app.state).to.equal("home");
+ });
+
+ it("Should go to verb settings when on verb quizzer", function() {
+ // Set state and test Back method
+ app.state = "verbQuizzer";
+ app.Back();
+ expect(app.state).to.equal("verbSettings");
+ });
+
+ it("Should go to vocab settings when on vocab quizzer", function() {
+ // Set state and test Back method
+ app.state = "vocabQuizzer";
+ app.Back();
+ expect(app.state).to.equal("vocabSettings");
+ });
+ });
+
+ describe("AddVerbFilter method", function() {
+ it("Should add a verb filter", function() {
+ // Assert filters is empty
+ expect(app.verbFilters.length).to.equal(0);
+
+ // Add filter
+ app.AddVerbFilter();
+
+ // Assert filter added
+ expect(app.verbFilters.length).to.equal(1);
+ expect(app.verbFilters[0]["tense"]).to.equal("All Tenses");
+ expect(app.verbFilters[0]["type"]).to.equal("All Types");
+ });
+ });
+
+ describe("RemoveVerbFilter method", function() {
+ it("Should remove the specified filter", function() {
+ // Initialize filters
+ app.verbFilters = [
+ {"tense":"Present Tense", "type":"All Types"},
+ {"tense":"Preterite Tense", "type":"All Types"},
+ {"tense":"Imperfect Tense", "type":"All Types"}
+ ]
+
+ // Remove filter
+ app.RemoveVerbFilter(1);
+
+ // Assert filter removed
+ expect(app.verbFilters.length).to.equal(2);
+ expect(app.verbFilters[0]["tense"]).to.equal("Present Tense");
+ expect(app.verbFilters[0]["type"]).to.equal("All Types");
+ expect(app.verbFilters[1]["tense"]).to.equal("Imperfect Tense");
+ expect(app.verbFilters[1]["type"]).to.equal("All Types");
+ });
+ });
+
+ describe("AddVocabFilter method", function() {
+ it("Should add a vocab filter", function() {
+ // Assert filters is empty
+ expect(app.vocabFilters.length).to.equal(0);
+
+ // Add filter
+ app.AddVocabFilter();
+
+ // Assert filter added
+ expect(app.vocabFilters.length).to.equal(1);
+ expect(app.vocabFilters[0]["set"]).to.equal("Verbs");
+ expect(app.vocabFilters[0]["type"]).to.equal("All Definitions");
+ });
+ });
+
+ describe("RemoveVocabFilter method", function() {
+ it("Should remove the specified filter", function() {
+ // Initialize filters
+ app.vocabFilters = [
+ {"set":"Verbs", "type":"All Definitions"},
+ {"set":"Adjectives", "type":"All Definitions"},
+ {"set":"Adverbs", "type":"All Definitions"},
+ ]
+
+ // Remove filter
+ app.RemoveVocabFilter(1);
+
+ // Assert filter removed
+ expect(app.vocabFilters.length).to.equal(2);
+ expect(app.vocabFilters[0]["set"]).to.equal("Verbs");
+ expect(app.vocabFilters[0]["type"]).to.equal("All Definitions");
+ expect(app.vocabFilters[1]["set"]).to.equal("Adverbs");
+ expect(app.vocabFilters[1]["type"]).to.equal("All Definitions");
+ });
+ });
+
+ describe("GetTenseTypes method", function() {
+ it("Should be correct for All Tenses", function() {
+ // Initialize filters
+ app.verbFilters = [
+ {"tense":"All Types", "type":"All Types"}
+ ]
+
+ // Get filters
+ let filters = app.getTenseTypes(0);
+
+ // Assert filters are correct
+ expect(filters["All Types"]).to.equal(true);
+ expect(filters["Reflexive"]).to.equal(true);
+ expect(filters["Regular"]).to.equal(true);
+ expect(filters["Nonregular"]).to.equal(true);
+ expect(filters["Stem Changing"]).to.equal(true);
+ expect(filters["Orthographic"]).to.equal(true);
+ expect(filters["Irregular"]).to.equal(true);
+ });
+
+ it("Should be correct for Present Tense", function() {
+ // Initialize filters
+ app.verbFilters = [
+ {"tense":"Present Tense", "type":"All Types"}
+ ]
+
+ // Get filters
+ let filters = app.getTenseTypes(0);
+
+ // Assert filters are correct
+ expect(filters["All Types"]).to.equal(true);
+ expect(filters["Reflexive"]).to.equal(true);
+ expect(filters["Regular"]).to.equal(true);
+ expect(filters["Nonregular"]).to.equal(true);
+ expect(filters["Stem Changing"]).to.equal(true);
+ expect(filters["Orthographic"]).to.equal(false);
+ expect(filters["Irregular"]).to.equal(true);
+ });
+
+ it("Should change selection if not available", function() {
+ // Initialize filters
+ app.verbFilters = [
+ {"tense":"Present Tense", "type":"Orthographic"}
+ ]
+
+ // Get filters
+ let filters = app.getTenseTypes(0);
+
+ // Assert filters are correct
+ expect(filters["All Types"]).to.equal(true);
+ expect(filters["Reflexive"]).to.equal(true);
+ expect(filters["Regular"]).to.equal(true);
+ expect(filters["Nonregular"]).to.equal(true);
+ expect(filters["Stem Changing"]).to.equal(true);
+ expect(filters["Orthographic"]).to.equal(false);
+ expect(filters["Irregular"]).to.equal(true);
+
+ // Assert selection changed
+ expect(app.verbFilters[0]["type"]).to.equal("All Types");
+ });
+
+ it("Should not change selection if available", function() {
+ // Initialize filters
+ app.verbFilters = [
+ {"tense":"Preterite Tense", "type":"Orthographic"}
+ ]
+
+ // Get filters
+ let filters = app.getTenseTypes(0);
+
+ // Assert filters are correct
+ expect(filters["All Types"]).to.equal(true);
+ expect(filters["Reflexive"]).to.equal(true);
+ expect(filters["Regular"]).to.equal(true);
+ expect(filters["Nonregular"]).to.equal(true);
+ expect(filters["Stem Changing"]).to.equal(true);
+ expect(filters["Orthographic"]).to.equal(true);
+ expect(filters["Irregular"]).to.equal(true);
+
+ // Assert selection not changed
+ expect(app.verbFilters[0]["type"]).to.equal("Orthographic");
+ });
+ });
+
+ describe("GetSetFilters method", function() {
+ it("Should be correct for Verbs", function() {
+ // Initialize filters
+ app.vocabFilters = [
+ {"set":"Verbs", "type":"All Definitions"}
+ ]
+
+ // Get filters
+ let actual = app.getSetFilters(0);
+
+ // Assert filters are correct
+ let expected = ["All Definitions", "Spanish Infinitives", "English Infinitives", "Reverse Conjugations"];
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i]).to.equal(expected[i]);
+ }
+ });
+
+ it("Should be correct for sets with 1 type", function() {
+ // Initialize filters
+ app.vocabFilters = [
+ {"set":"Colors", "type":"All Definitions"}
+ ]
+
+ // Get filters
+ let actual = app.getSetFilters(0);
+
+ // Assert filters are correct
+ let expected = ["All Definitions", "English to Spanish", "Spanish to English"];
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i]).to.equal(expected[i]);
+ }
+ });
+
+ it("Should change selection if not available", function() {
+ // Initialize filters
+ app.vocabFilters = [
+ {"set":"Colors", "type":"Verbs"}
+ ]
+
+ // Get filters
+ app.getSetFilters(0);
+
+ // Assert selection changed
+ expect(app.vocabFilters[0]["type"]).to.equal("All Definitions");
+ });
+
+ it("Should not change selection if available", function() {
+ // Initialize filters
+ app.vocabFilters = [
+ {"set":"Professions", "type":"Verbs"}
+ ]
+
+ // Get filters
+ app.getSetFilters(0);
+
+ // Assert selection not changed
+ expect(app.vocabFilters[0]["type"]).to.equal("Verbs");
+ });
+ });
+
+ describe("GetLang method", function () {
+ it("Should return English by default", function() {
+ expect(app.getLang("")).to.equal("en");
+ expect(app.getLang("test")).to.equal("en");
+ });
+
+ it("Should return English for English labels", function() {
+ expect(app.getLang("test english test")).to.equal("en");
+ expect(app.getLang("ENGLISH")).to.equal("en");
+ })
+
+ it("Should return Spanish for Spanish labels", function() {
+ expect(app.getLang("test spanish test")).to.equal("es");
+ expect(app.getLang("SPANISH")).to.equal("es");
+ })
+ });
+
+ describe("Prompt property", function() {
+ it("Should be empty if there aren't any prompt", function() {
+ // Assert prompts and promptIndex are correct
+ expect(app.promptIndex).to.equal(0);
+ expect(app.prompts.length).to.equal(0);
+
+ // Assert prompt is empty
+ expect(app.prompt.length).to.equal(4);
+ expect(app.prompt[0]).to.equal("");
+ expect(app.prompt[1]).to.equal("");
+ expect(app.prompt[2]).to.equal("");
+ expect(app.prompt[3]).to.equal("");
+ });
+
+ it("Should be empty if promptIndex is invalid", function() {
+ // Initialize promptIndex
+ app.promptIndex = 2;
+
+ // Assert prompts is correct
+ expect(app.prompts.length).to.equal(0);
+
+ // Assert prompt is empty
+ expect(app.prompt.length).to.equal(4);
+ expect(app.prompt[0]).to.equal("");
+ expect(app.prompt[1]).to.equal("");
+ expect(app.prompt[2]).to.equal("");
+ expect(app.prompt[3]).to.equal("");
+ });
+
+ it("Should be the current prompt if promptIndex is valid", function() {
+ // Initialize prompts and promptIndex
+ app.promptIndex = 1;
+ app.prompts = [
+ ["a1", "b1", "c1", "d1"],
+ ["a2", "b2", "c2", "d2"],
+ ["a3", "b3", "c3", "d3"],
+ ];
+
+ // Assert prompt is correct
+ expect(app.prompt.length).to.equal(4);
+ expect(app.prompt[0]).to.equal("a2");
+ expect(app.prompt[1]).to.equal("b2");
+ expect(app.prompt[2]).to.equal("c2");
+ expect(app.prompt[3]).to.equal("d2");
+ });
+ });
+
+ describe("PromptType watch", function() {
+ it("Should update setting in localStorage", function() {
+ // Save original setting from localStorage
+ let originalValue = localStorage.getItem("promptType");
+
+ // Set promptType
+ app.promptType = "test";
+
+ // Assert localStorage setting updated
+ expect(localStorage.getItem("promptType")).to.equal("test");
+
+ // Restore original setting to localStorage
+ localStorage.setItem("promptType", originalValue);
+ });
+ });
+
+ describe("InputType watch", function() {
+ it("Should update setting in localStorage", function() {
+ // Save original setting from localStorage
+ let originalValue = localStorage.getItem("inputType");
+
+ // Set inputType
+ app.inputType = "test";
+
+ // Assert localStorage setting updated
+ expect(localStorage.getItem("inputType")).to.equal("test");
+
+ // Restore original setting to localStorage
+ localStorage.setItem("inputType", originalValue);
+ });
+ });
+
+ describe("RepeatPrompts watch", function() {
+ it("Should update setting in localStorage", function() {
+ // Save original setting from localStorage
+ let originalValue = localStorage.getItem("repeatPrompts");
+
+ // Set repeatPrompts
+ app.repeatPrompts = "test";
+
+ // Assert localStorage setting updated
+ expect(localStorage.getItem("repeatPrompts")).to.equal("test");
+
+ // Restore original setting to localStorage
+ localStorage.setItem("repeatPrompts", originalValue);
+ });
+ });
+});
diff --git a/Tests/test.quizzer.js b/Tests/test.quizzer.js
@@ -0,0 +1,17 @@
+describe("Quizzer", function() {
+ describe("Shuffle method", function() {
+ it("Should not alter list", function() {
+ // Initialize list
+ let list1 = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"]; // 15 items
+
+ // Shuffle list
+ let list2 = Shuffle(list1);
+
+ // Assert list shuffled
+ expect(list2.length).to.equal(list1.length);
+ for (let item of list2) {
+ expect(list1.includes(item)).to.equal(true);
+ }
+ });
+ });
+});
diff --git a/Tests/test.settings.js b/Tests/test.settings.js
@@ -0,0 +1,442 @@
+describe("Settings", function() {
+ describe("ApplyVocabFilter method", function() {
+ // Initialize vocab
+ let vocab = [
+ ["Upper", "Lower", "Type"],
+ ["A", "a", "Noun"],
+ ["B", "b", "Adjective"],
+ ["C", "c", "Verb"]
+ ];
+
+ it("Should correctly filter vocab for All Definitions", function() {
+ // Initialize expected
+ let expected = [
+ ["Upper", "A", "Lower", "a"],
+ ["Upper", "B", "Lower", "b"],
+ ["Upper", "C", "Lower", "c"],
+ ["Lower", "a", "Upper", "A"],
+ ["Lower", "b", "Upper", "B"],
+ ["Lower", "c", "Upper", "C"],
+ ];
+
+ // Filter vocab
+ let actual = ApplyVocabFilter(vocab, "All Definitions");
+
+ // Assert filtered vocab is correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter vocab for English to Spanish", function() {
+ // Initialize expected
+ let expected = [
+ ["Upper", "A", "Lower", "a"],
+ ["Upper", "B", "Lower", "b"],
+ ["Upper", "C", "Lower", "c"],
+ ];
+
+ // Filter vocab
+ let actual = ApplyVocabFilter(vocab, "English to Spanish");
+
+ // Assert filtered vocab is correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter vocab for Spanish to English", function() {
+ // Initialize expected
+ let expected = [
+ ["Lower", "a", "Upper", "A"],
+ ["Lower", "b", "Upper", "B"],
+ ["Lower", "c", "Upper", "C"],
+ ];
+
+ // Filter vocab
+ let actual = ApplyVocabFilter(vocab, "Spanish to English");
+
+ // Assert filtered vocab is correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter vocab for Nouns", function() {
+ // Initialize expected
+ let expected = [
+ ["Upper", "A", "Lower", "a"],
+ ["Lower", "a", "Upper", "A"],
+ ];
+
+ // Filter vocab
+ let actual = ApplyVocabFilter(vocab, "Nouns");
+
+ // Assert filtered vocab is correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter vocab for Adjectives", function() {
+ // Initialize expected
+ let expected = [
+ ["Upper", "B", "Lower", "b"],
+ ["Lower", "b", "Upper", "B"],
+ ];
+
+ // Filter vocab
+ let actual = ApplyVocabFilter(vocab, "Adjectives");
+
+ // Assert filtered vocab is correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter vocab for Verbs", function() {
+ // Initialize expected
+ let expected = [
+ ["Upper", "C", "Lower", "c"],
+ ["Lower", "c", "Upper", "C"],
+ ];
+
+ // Filter vocab
+ let actual = ApplyVocabFilter(vocab, "Verbs");
+
+ // Assert filtered vocab is correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should return empty list by default", function() {
+ // Assert result is empty by default
+ expect(ApplyVocabFilter(vocab, "test").length).to.equal(0);
+ expect(ApplyVocabFilter(vocab, "").length).to.equal(0);
+ expect(ApplyVocabFilter(vocab, 1).length).to.equal(0);
+ expect(ApplyVocabFilter(vocab, null).length).to.equal(0);
+ });
+ });
+
+ describe("ApplyVerbFilter method", function() {
+ // Initialize verbs
+ // Headers are capitalized to tell them apart from the other rows
+ let verbs = [
+ ["KEY", "SPANISH INF", "TYPE", "1A", "TYPE", "2A", "2B", "2C", "2D", "2E", "TYPE", "3A", "3B", "3C", "3D", "3E", "TYPE", "4A", "4B", "4C", "4D", "4E"],
+ ["key", "spanish inf", "Regular", "1a", "Irregular", "2a", "2b", "2c", "2d", "2e", "Orthographic", "3a", "3b", "3c", "3d", "3e", "Stem Changing", "4a", "4b", "4c", "4d", "4e"],
+ ];
+
+ it("Should correctly filter verbs for All Conjugatinos", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "1A", "1a"],
+ ["KEY", "key", "2A", "2a"],
+ ["KEY", "key", "2B", "2b"],
+ ["KEY", "key", "2C", "2c"],
+ ["KEY", "key", "2D", "2d"],
+ ["KEY", "key", "2E", "2e"],
+ ["KEY", "key", "3A", "3a"],
+ ["KEY", "key", "3B", "3b"],
+ ["KEY", "key", "3C", "3c"],
+ ["KEY", "key", "3D", "3d"],
+ ["KEY", "key", "3E", "3e"],
+ ["KEY", "key", "4A", "4a"],
+ ["KEY", "key", "4B", "4b"],
+ ["KEY", "key", "4C", "4c"],
+ ["KEY", "key", "4D", "4d"],
+ ["KEY", "key", "4E", "4e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"all"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter verbs for Present Participles", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "1A", "1a"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"Present Participles", "type":"all"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter verbs for Present Tense", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "2A", "2a"],
+ ["KEY", "key", "2B", "2b"],
+ ["KEY", "key", "2C", "2c"],
+ ["KEY", "key", "2D", "2d"],
+ ["KEY", "key", "2E", "2e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"Present Tense", "type":"all"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter verbs for Preterite Tense", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "3A", "3a"],
+ ["KEY", "key", "3B", "3b"],
+ ["KEY", "key", "3C", "3c"],
+ ["KEY", "key", "3D", "3d"],
+ ["KEY", "key", "3E", "3e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"Preterite Tense", "type":"all"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter verbs for Imperfect Tense", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "4A", "4a"],
+ ["KEY", "key", "4B", "4b"],
+ ["KEY", "key", "4C", "4c"],
+ ["KEY", "key", "4D", "4d"],
+ ["KEY", "key", "4E", "4e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"Imperfect Tense", "type":"all"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter regular verbs", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "1A", "1a"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"Regular"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter stem changing verbs", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "4A", "4a"],
+ ["KEY", "key", "4B", "4b"],
+ ["KEY", "key", "4C", "4c"],
+ ["KEY", "key", "4D", "4d"],
+ ["KEY", "key", "4E", "4e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"Stem Changing"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter orthographic verbs", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "3A", "3a"],
+ ["KEY", "key", "3B", "3b"],
+ ["KEY", "key", "3C", "3c"],
+ ["KEY", "key", "3D", "3d"],
+ ["KEY", "key", "3E", "3e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"Orthographic"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter irregular verbs", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "2A", "2a"],
+ ["KEY", "key", "2B", "2b"],
+ ["KEY", "key", "2C", "2c"],
+ ["KEY", "key", "2D", "2d"],
+ ["KEY", "key", "2E", "2e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"irregular"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter nonregular verbs", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "2A", "2a"],
+ ["KEY", "key", "2B", "2b"],
+ ["KEY", "key", "2C", "2c"],
+ ["KEY", "key", "2D", "2d"],
+ ["KEY", "key", "2E", "2e"],
+ ["KEY", "key", "3A", "3a"],
+ ["KEY", "key", "3B", "3b"],
+ ["KEY", "key", "3C", "3c"],
+ ["KEY", "key", "3D", "3d"],
+ ["KEY", "key", "3E", "3e"],
+ ["KEY", "key", "4A", "4a"],
+ ["KEY", "key", "4B", "4b"],
+ ["KEY", "key", "4C", "4c"],
+ ["KEY", "key", "4D", "4d"],
+ ["KEY", "key", "4E", "4e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"Nonregular"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+
+ it("Should correctly filter verbs for multiple filters", function() {
+ // Initialize expected
+ let expected = [
+ ["KEY", "key", "2A", "2a"],
+ ["KEY", "key", "2B", "2b"],
+ ["KEY", "key", "2C", "2c"],
+ ["KEY", "key", "2D", "2d"],
+ ["KEY", "key", "2E", "2e"],
+ ["KEY", "key", "3A", "3a"],
+ ["KEY", "key", "3B", "3b"],
+ ["KEY", "key", "3C", "3c"],
+ ["KEY", "key", "3D", "3d"],
+ ["KEY", "key", "3E", "3e"],
+ ["KEY", "key", "4A", "4a"],
+ ["KEY", "key", "4B", "4b"],
+ ["KEY", "key", "4C", "4c"],
+ ["KEY", "key", "4D", "4d"],
+ ["KEY", "key", "4E", "4e"],
+
+ ["KEY", "key", "2A", "2a"],
+ ["KEY", "key", "2B", "2b"],
+ ["KEY", "key", "2C", "2c"],
+ ["KEY", "key", "2D", "2d"],
+ ["KEY", "key", "2E", "2e"],
+
+ ["KEY", "key", "4A", "4a"],
+ ["KEY", "key", "4B", "4b"],
+ ["KEY", "key", "4C", "4c"],
+ ["KEY", "key", "4D", "4d"],
+ ["KEY", "key", "4E", "4e"],
+ ];
+
+ // Filter verbs
+ let actual = ApplyVerbFilter(verbs, [{"tense":"all", "type":"Nonregular"}, {"tense":"Present Tense", "type":"all"}, {"tense":"all", "type":"Stem Changing"}]);
+
+ // Assert filtered verbs are correct
+ expect(actual.length).to.equal(expected.length);
+ for (let i = 0; i < expected.length; i++) {
+ expect(actual[i].length).to.equal(4);
+ for (let j = 0; j < expected[i].length; j++) {
+ expect(actual[i][j]).to.equal(expected[i][j]);
+ }
+ }
+ });
+ });
+});