spanish-quizzer

An app to quiz you on Spanish vocabulary and verb conjugations
git clone https://git.ashermorgan.net/spanish-quizzer/
Log | Files | Refs | README

test.reference.js (4949B)


      1 describe("ReferenceTables", function() {
      2     let ReferenceTables;
      3     beforeEach(function() {
      4         // Create referenceTables component
      5         ReferenceTables = new referenceTables();
      6     });
      7 
      8     describe("Initial state", function() {
      9         it("Category should be 'Choose a category'", function() {
     10             expect(ReferenceTables.category).to.equal("Choose a category");
     11         });
     12 
     13         it("ConjugationColors should be true", function() {
     14             expect(ReferenceTables.conjugationColors).to.be.true;
     15         });
     16 
     17         it("tableTheme should be null", function() {
     18             expect(ReferenceTables.tableTheme).to.be.null;
     19         });
     20     });
     21 
     22     describe("ConjugationColorClasses property", function() {
     23         it("Should produce correct color", function() {
     24             // Set reference tables data
     25             ReferenceTables.data = {verbs:[
     26                 // Test table headers
     27                 ["English", "Infinitive","Present Type","Present Yo","Present Tú","Present Él","Present Nosotros","Present Ellos","Preterite Type","Preterite Yo","Preterite Tú","Preterite Él","Preterite Nosotros","Preterite Ellos"],
     28 
     29                 // Test regular conjugations and orthographic conjugations
     30                 ["To read","Leer","Regular","Leo","Lees","Lee","Leemos","Leen","Orthographic","Leí","Leíste","Leyó","Leímos","Leyeron"],
     31 
     32                 // Test stem changing conjugations and irregular conjugations
     33                 ["To want","Querer","Stem Changing","Quiero","Quieres","Quiere","Queremos","Quieren","Irregular","Quise","Quisiste","Quiso","Quisimos","Quisieron"],
     34 
     35                 // Test irregular and stem changing conjugations
     36                 ["To have","Tener","Irregular, Stem Changing","Tengo","Tienes","Tiene","Tenemos","Tienen","Irregular","Tuve","Tuviste","Tuvo","Tuvimos","Tuvieron"],
     37 
     38                 // Test reflexive conjugations
     39                 ["To go to bed","Acostarse","Reflexive, Stem Changing","Me acuesto","Te acuestas","Se acuesta","Nos acostamos","Se acuestan","Reflexive, Regular","Me acosté","Te acostaste","Se acostó","Nos acostamos","Se acostaron"],
     40             ]};
     41 
     42             // Assert conjugationColorClasses is correct
     43             expect(ReferenceTables.conjugationColorClasses).to.deep.equal([
     44                 // Test regular conjugations and orthographic conjugations
     45                 ["normal","normal","regular","regular","regular","regular","regular","regular","nonregular","nonregular","nonregular","nonregular","nonregular","nonregular"],
     46 
     47                 // Test stem changing conjugations and irregular conjugations
     48                 ["normal","normal","nonregular","nonregular","nonregular","nonregular","nonregular","nonregular","irregular","irregular","irregular","irregular","irregular","irregular"],
     49 
     50                 // Test irregular and stem changing conjugations
     51                 ["normal","normal","irregular","irregular","irregular","irregular","irregular","irregular","irregular","irregular","irregular","irregular","irregular","irregular"],
     52 
     53                 // Test reflexive conjugations
     54                 ["normal","normal","nonregular","nonregular","nonregular","nonregular","nonregular","nonregular","regular","regular","regular","regular","regular","regular"],
     55             ]);
     56         });
     57     });
     58 
     59     describe("TableData property", function() {
     60         it("Should be calculated correctly", function() {
     61             // Set reference tables data
     62             let data = {verbs:[
     63                 // Test table headers
     64                 ["English", "Infinitive","Present Type","Present Yo","Present Tú","Present Él","Present Nosotros","Present Ellos","Preterite Type","Preterite Yo","Preterite Tú","Preterite Él","Preterite Nosotros","Preterite Ellos"],
     65 
     66                 // Test regular conjugations and orthographic conjugations
     67                 ["To read","Leer","Regular","Leo","Lees","Lee","Leemos","Leen","Orthographic","Leí","Leíste","Leyó","Leímos","Leyeron"],
     68 
     69                 // Test stem changing conjugations and irregular conjugations
     70                 ["To want","Querer","Stem Changing","Quiero","Quieres","Quiere","Queremos","Quieren","Irregular","Quise","Quisiste","Quiso","Quisimos","Quisieron"],
     71 
     72                 // Test irregular and stem changing conjugations
     73                 ["To have","Tener","Irregular, Stem Changing","Tengo","Tienes","Tiene","Tenemos","Tienen","Irregular","Tuve","Tuviste","Tuvo","Tuvimos","Tuvieron"],
     74 
     75                 // Test reflexive conjugations
     76                 ["To go to bed","Acostarse","Reflexive, Stem Changing","Me acuesto","Te acuestas","Se acuesta","Nos acostamos","Se acuestan","Reflexive, Regular","Me acosté","Te acostaste","Se acostó","Nos acostamos","Se acostaron"],
     77             ]};
     78             ReferenceTables.data = data;
     79 
     80             // Assert tableData is correct
     81             expect(ReferenceTables.tableData).to.deep.equal({...{"Choose a category":[]}, ...data});
     82         });
     83     });
     84 });