Currency abbrev should be exactly 3 characters
authorLinda Nichols <lynnaloo@gmail.com>
Wed, 27 Aug 2014 16:04:39 +0000 (16:04 +0000)
committerLinda Nichols <lynnaloo@gmail.com>
Wed, 27 Aug 2014 16:04:39 +0000 (16:04 +0000)
enyo-client/application/source/models/address.js
test/specs/country.js

index 900fe15..c3ae3c8 100644 (file)
@@ -127,7 +127,7 @@ white:true*/
       }
 
       if (attributes.currencyNumber &&
-          attributes.currencyNumber.length > 3) {
+          attributes.currencyNumber.length !== 3) {
         params.attr = "_currencyNumber".loc();
         params.length = "3";
         return XT.Error.clone('xt1006', { params: params });
index 3e0875f..3be3de5 100644 (file)
@@ -82,25 +82,32 @@ setTimeout:true, before:true, clearTimeout:true, exports:true, it:true, describe
       /**
         @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
+        @description Length of Abbreviation field should be 2, Currency Abbreviation
+        and Currency Number should be 3
       */
+      it("Abbreviation length should be less than 2", function () {
+        countryModel.set("abbreviation", "A");
+        assert.isObject(countryModel.validate(countryModel.attributes));
+      });
+      it("Length of Currency Abbreviation should not be less than 3", function () {
+        countryModel.set("currencyAbbreviation", "AB");
+        assert.isObject(countryModel.validate(countryModel.attributes));
+      });
+      it("Currency Number length should not be less than 3", function () {
+        countryModel.set("currencyNumber", "AB");
+        assert.isObject(countryModel.validate(countryModel.attributes));
+      });
+
       it("Abbreviation length should not exceed 2", function () {
-        countryModel.set("abbreviation", "22");
-        assert.isUndefined(JSON.stringify(countryModel.validate(countryModel.attributes)));
-        countryModel.set("abbreviation", "333");
+        countryModel.set("abbreviation", "ABC");
         assert.isObject(countryModel.validate(countryModel.attributes));
       });
       it("Length of Currency Abbreviation should not exceed 3", function () {
-        countryModel.set("currencyAbbreviation", "333");
-        assert.isUndefined(JSON.stringify(countryModel.validate(countryModel.attributes)));
-        countryModel.set("currencyAbbreviation", "4444");
+        countryModel.set("currencyAbbreviation", "ABCD");
         assert.isObject(countryModel.validate(countryModel.attributes));
       });
-      it("Currency Number length should not exceed 3 ", function () {
-        countryModel.set("currencyNumber", "333");
-        assert.isUndefined(JSON.stringify(countryModel.validate(countryModel.attributes)));
-        countryModel.set("currencyNumber", "4444");
+      it("Currency Number length should not exceed 3", function () {
+        countryModel.set("currencyNumber", "ABCD");
         assert.isObject(countryModel.validate(countryModel.attributes));
       });
     });