Bläddra i källkod

[core] Adjust autocomplete tests to also check for the correct order of the suggestions

Johan Ahlen 10 år sedan
förälder
incheckning
83fa44b

+ 2 - 6
desktop/core/src/desktop/static/desktop/spec/autocompleterTestUtils.js

@@ -20,17 +20,13 @@ define([
       toEqualAutocompleteValues : function() {
         return {
           compare: function(actualItems, expectedValues) {
-            var itemIndex = {};
-
             if (actualItems.length !== expectedValues.length) {
               return { pass: false };
             }
-            $.each(actualItems, function(i, item) {
-              itemIndex[item.value] = true;
-            });
 
             for (var i = 0; i < expectedValues.length; i++) {
-              if (! itemIndex[expectedValues[i]]) {
+              var stringValue = typeof actualItems[i] !== "string" ? '' + actualItems[i].value : actualItems[i].value;
+              if (stringValue !== expectedValues[i]) {
                 return { pass: false };
               }
             }

+ 3 - 3
desktop/core/src/desktop/static/desktop/spec/sqlAutocompleterSpec.js

@@ -249,7 +249,7 @@ define([
           serverResponses: {},
           beforeCursor: "SELECT ",
           afterCursor: " FROM testTableA   tta, testTableB",
-          expectedSuggestions: ["testTableB.", "tta."]
+          expectedSuggestions: ["tta.", "testTableB."]
         });
       });
 
@@ -258,7 +258,7 @@ define([
           serverResponses: {},
           beforeCursor: "SELECT * FROM testTableA tta, testTableB GROUP BY ",
           afterCursor: "",
-          expectedSuggestions: ["testTableB.", "tta."]
+          expectedSuggestions: ["tta.", "testTableB."]
         });
       });
 
@@ -556,7 +556,7 @@ define([
             },
             beforeCursor: "SELECT ",
             afterCursor: " FROM testTable LATERAL VIEW explode(testMap) explodedMap AS (testMapKey, testMapValue)",
-            expectedSuggestions: ["*", "explodedMap", "testTableColumn1", "testTableColumn2", "testMapKey", "testMapValue"]
+            expectedSuggestions: ["*", "explodedMap", "testMapKey", "testMapValue", "testTableColumn1", "testTableColumn2"]
           });
         });
       });