Added validation for currency abbrev on Country
authorLinda Nichols <lynnaloo@gmail.com>
Wed, 27 Aug 2014 06:10:26 +0000 (06:10 +0000)
committerLinda Nichols <lynnaloo@gmail.com>
Wed, 27 Aug 2014 06:10:26 +0000 (06:10 +0000)
enyo-client/application/source/models/address.js
enyo-client/application/source/views/workspace.js
test/specs/country.js

index f15e09a..900fe15 100644 (file)
@@ -125,6 +125,14 @@ white:true*/
         params.length = "3";
         return XT.Error.clone('xt1006', { params: params });
       }
+
+      if (attributes.currencyNumber &&
+          attributes.currencyNumber.length > 3) {
+        params.attr = "_currencyNumber".loc();
+        params.length = "3";
+        return XT.Error.clone('xt1006', { params: params });
+      }
+
       return XM.Document.prototype.validate.apply(this, arguments);
     }
 
index a0e9ba6..345ccb0 100644 (file)
@@ -641,12 +641,12 @@ strict: false*/
           {kind: "onyx.GroupboxHeader", content: "_overview".loc()},
           {kind: "XV.ScrollableGroupbox", name: "mainGroup",
             classes: "in-panel", components: [
-            {kind: "XV.InputWidget", attr: "abbreviation"},
+            {kind: "XV.InputWidget", attr: "abbreviation", maxlength: 2},
             {kind: "XV.InputWidget", attr: "name"},
             {kind: "XV.InputWidget", attr: "currencyName"},
             {kind: "XV.InputWidget", attr: "currencySymbol"},
-            {kind: "XV.InputWidget", attr: "currencyAbbreviation"},
-            {kind: "XV.InputWidget", attr: "currencyNumber"}
+            {kind: "XV.InputWidget", attr: "currencyAbbreviation", maxlength: 3},
+            {kind: "XV.InputWidget", attr: "currencyNumber", maxlength: 3}
           ]}
         ]}
       ]}
index 0a6659c..f191a49 100644 (file)
@@ -70,18 +70,37 @@ setTimeout:true, before:true, clearTimeout:true, exports:true, it:true, describe
     updatableField: "name"
   };
   var additionalTests = function () {
-    /**
-      @member -
-      @memberof Country.prototype
-      @description Length of Abbreviation field should not exceed 2, Currency Abbreviation
-      and Currency Number should not exceed 3 and Currency Number value should be an integer
-    */
-    it.skip("Abbreviation length should not exceed 2", function () {
-    });
-    it.skip("Length of Currency Abbreviation should not exceed 3", function () {
-    });
-    it.skip("Currency Number value should be an integer and its length should not" +
-    " exceed 3 ", function () {
+    describe("Incident status behavior", function () {
+      var countryModel;
+
+      beforeEach(function () {
+        countryModel = new XM.Country();
+        countryModel.initialize(null, {isNew: true});
+      });
+      /**
+        @member -
+        @memberof Country.prototype
+        @description Length of Abbreviation field should not exceed 2, Currency Abbreviation
+        and Currency Number should not exceed 3 and Currency Number value should be an integer
+      */
+      it.skip("Abbreviation length should not exceed 2", function () {
+        countryModel.set("abbreviation", "22");
+        assert.isUndefined(countryModel.validate(countryModel.attributes));
+        countryModel.set("abbreviation", "333");
+        assert.isObject(countryModel.validate(countryModel.attributes));
+      });
+      it.skip("Length of Currency Abbreviation should not exceed 3", function () {
+        countryModel.set("abbreviation", "333");
+        assert.isUndefined(countryModel.validate(countryModel.attributes));
+        countryModel.set("abbreviation", "4444");
+        assert.isObject(countryModel.validate(countryModel.attributes));
+      });
+      it.skip("Currency Number length should not exceed 3 ", function () {
+        countryModel.set("abbreviation", "333");
+        assert.isUndefined(countryModel.validate(countryModel.attributes));
+        countryModel.set("abbreviation", "4444");
+        assert.isObject(countryModel.validate(countryModel.attributes));
+      });
     });
   };
   exports.spec = spec;