incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1393847 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-web/app/models/ ambari-web/app/views/main/admin/user/ ambari-web/test/main/ ambari-web/test/main/host/ ambari-web/test/utils/
Date Thu, 04 Oct 2012 00:12:18 GMT
Author: yusaku
Date: Thu Oct  4 00:12:18 2012
New Revision: 1393847

URL: http://svn.apache.org/viewvc?rev=1393847&view=rev
Log:
AMBARI-804. Fix routing issues with Admin pages. (yusaku)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-web/app/models/form.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js
    incubator/ambari/branches/AMBARI-666/ambari-web/test/main/dashboard_test.js
    incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host/details_test.js
    incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host_test.js
    incubator/ambari/branches/AMBARI-666/ambari-web/test/utils/form_field_test.js

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Thu Oct  4 00:12:18 2012
@@ -224,6 +224,8 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-804. Fix routing issues with Admin pages. (yusaku)
+
   AMBARI-798. Fix import issue due to move of Predicate class. (hitesh)
 
   AMBARI-780. Make FSM related changes for heartbeat handler. (hitesh)

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/models/form.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/models/form.js?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/models/form.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/models/form.js Thu Oct  4 00:12:18
2012
@@ -118,7 +118,7 @@ App.Form = Em.View.extend({
       });
     } else {
       if (this.get('className'))
-        App.store.createRecord(App.User, this.getValues())
+        App.store.createRecord(this.get('className'), this.getValues())
       else
         console.log("Please define class name for your form " + this.constructor);
     }

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js Thu
Oct  4 00:12:18 2012
@@ -24,7 +24,7 @@ App.MainAdminUserEditView = Em.View.exte
   create: function(event){
     var form = this.get("userForm");
     if(form.isValid() && form.save()) {
-      App.router.transitionTo("all");
+      App.router.transitionTo("allUsers");
     }
   },
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/test/main/dashboard_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/test/main/dashboard_test.js?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/test/main/dashboard_test.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/test/main/dashboard_test.js Thu Oct  4
00:12:18 2012
@@ -1,34 +1,34 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-
-require('models/alert'); 
-App.Alert.FIXTURES = [{ status: 'ok' }, { status: 'corrupt' }, { status: 'corrupt',}];
-require('controllers/main/dashboard');
- 
-describe('MainDashboard', function () {
- 
-  var controller = App.MainDashboardController.create();
-  
-  describe('#alertsCount', function () {
-    it('should return 2 if 2 alerts has status corrupt', function () {
-        expect(controller.get('alertsCount')).to.equal(2);
-    })
-  })
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+require('models/alert'); 
+App.Alert.FIXTURES = [{ status: 'ok' }, { status: 'corrupt' }, { status: 'corrupt',}];
+require('controllers/main/dashboard');
+ 
+describe('MainDashboard', function () {
+ 
+  var controller = App.MainDashboardController.create();
+  
+  describe('#alertsCount', function () {
+    it('should return 2 if 2 alerts has status corrupt', function () {
+        expect(controller.get('alertsCount')).to.equal(2);
+    })
+  })
 })
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host/details_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host/details_test.js?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host/details_test.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host/details_test.js Thu Oct
 4 00:12:18 2012
@@ -1,49 +1,49 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var Ember = require('ember');
- var App = require('app');
- 
-require('controllers/main/host/details');
-
-describe('MainHostdetails', function () {
-  var controller = App.MainHostDetailsController.create();
-  controller.content = Ember.Object.create({});
-   
-  describe('#setBack(value)', function () {
-    it('should return true if value is true', function () {
-      controller.setBack(true);
-      expect(controller.get('isFromHosts')).to.equal(true);
-    })
-  }),
-  describe('#workStatus positive', function () {
-    it('should return true if workstatus is true', function () {
-      controller.content.set('workStatus',true);   
-      expect(controller.get('isStarting')).to.equal(true);
-      }),
-    it('should return false if workStatus is true', function () {
-      expect(controller.get('isStopping')).to.equal(false);
-    })
-    it('should return false if workstatus is false', function () {
-      controller.content.set('workStatus',false);   
-      expect(controller.get('isStarting')).to.equal(false);
-      }),
-    it('should return true if workStatus is false', function () {
-      expect(controller.get('isStopping')).to.equal(true);
-    })
-  })
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ var Ember = require('ember');
+ var App = require('app');
+ 
+require('controllers/main/host/details');
+
+describe('MainHostdetails', function () {
+  var controller = App.MainHostDetailsController.create();
+  controller.content = Ember.Object.create({});
+   
+  describe('#setBack(value)', function () {
+    it('should return true if value is true', function () {
+      controller.setBack(true);
+      expect(controller.get('isFromHosts')).to.equal(true);
+    })
+  }),
+  describe('#workStatus positive', function () {
+    it('should return true if workstatus is true', function () {
+      controller.content.set('workStatus',true);   
+      expect(controller.get('isStarting')).to.equal(true);
+      }),
+    it('should return false if workStatus is true', function () {
+      expect(controller.get('isStopping')).to.equal(false);
+    })
+    it('should return false if workstatus is false', function () {
+      controller.content.set('workStatus',false);   
+      expect(controller.get('isStarting')).to.equal(false);
+      }),
+    it('should return true if workStatus is false', function () {
+      expect(controller.get('isStopping')).to.equal(true);
+    })
+  })
 })
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host_test.js?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host_test.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/test/main/host_test.js Thu Oct  4 00:12:18
2012
@@ -1,84 +1,84 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-require('models/cluster');
-require('models/service');
-require('models/pagination');
-require('controllers/main/host');
-
-
-describe('MainHostController', function () {
-    describe('#sortByName()', function () {
-        it('should change isSort value to true', function () {
-            var mainHostController = App.MainHostController.create();
-            mainHostController.set('isSort', false);
-            mainHostController.sortByName();
-            expect(mainHostController.get('isSort')).to.equal(true);
-        });
-
-
-        it('should inverse sortingAsc ', function () {
-            var mainHostController = App.MainHostController.create();
-            mainHostController.set('sortingAsc', false);
-            mainHostController.sortByName();
-            expect(mainHostController.get('sortingAsc')).to.equal(true);
-            mainHostController.sortByName();
-            expect(mainHostController.get('sortingAsc')).to.equal(false);
-        })
-    });
-
-
-    describe('#showNextPage, #showPreviousPage()', function () {
-        it('should change rangeStart according to page', function () {
-            var mainHostController = App.MainHostController.create();
-            mainHostController.set('pageSize', 3);
-            mainHostController.showNextPage();
-            expect(mainHostController.get('rangeStart')).to.equal(3);
-            mainHostController.showPreviousPage();
-            expect(mainHostController.get('rangeStart')).to.equal(0);
-        })
-    });
-
-
-    describe('#sortClass()', function () {
-        it('should return \'icon-arrow-down\' if sortingAsc is true', function () {
-            var mainHostController = App.MainHostController.create({});
-            mainHostController.set('sortingAsc', true);
-            expect(mainHostController.get('sortClass')).to.equal('icon-arrow-down');
-        });
-        it('should return \'icon-arrow-up\' if sortingAsc is false', function () {
-            var mainHostController = App.MainHostController.create({});
-            mainHostController.set('sortingAsc', false);
-            expect(mainHostController.get('sortClass')).to.equal('icon-arrow-up');
-        })
-    });
-
-
-    describe('#allChecked', function () {
-        it('should fill selectedhostsids array', function () {
-            var mainHostController = App.MainHostController.create();
-            mainHostController.set('allChecked', false);
-            expect(mainHostController.get('selectedHostsIds').length).to.equal(0);
-            mainHostController.set('allChecked', true);
-            expect(!!(mainHostController.get('selectedHostsIds').length)).to.equal(true);
-        })
-    });
-
-
-});
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('models/cluster');
+require('models/service');
+require('models/pagination');
+require('controllers/main/host');
+
+
+describe('MainHostController', function () {
+    describe('#sortByName()', function () {
+        it('should change isSort value to true', function () {
+            var mainHostController = App.MainHostController.create();
+            mainHostController.set('isSort', false);
+            mainHostController.sortByName();
+            expect(mainHostController.get('isSort')).to.equal(true);
+        });
+
+
+        it('should inverse sortingAsc ', function () {
+            var mainHostController = App.MainHostController.create();
+            mainHostController.set('sortingAsc', false);
+            mainHostController.sortByName();
+            expect(mainHostController.get('sortingAsc')).to.equal(true);
+            mainHostController.sortByName();
+            expect(mainHostController.get('sortingAsc')).to.equal(false);
+        })
+    });
+
+
+    describe('#showNextPage, #showPreviousPage()', function () {
+        it('should change rangeStart according to page', function () {
+            var mainHostController = App.MainHostController.create();
+            mainHostController.set('pageSize', 3);
+            mainHostController.showNextPage();
+            expect(mainHostController.get('rangeStart')).to.equal(3);
+            mainHostController.showPreviousPage();
+            expect(mainHostController.get('rangeStart')).to.equal(0);
+        })
+    });
+
+
+    describe('#sortClass()', function () {
+        it('should return \'icon-arrow-down\' if sortingAsc is true', function () {
+            var mainHostController = App.MainHostController.create({});
+            mainHostController.set('sortingAsc', true);
+            expect(mainHostController.get('sortClass')).to.equal('icon-arrow-down');
+        });
+        it('should return \'icon-arrow-up\' if sortingAsc is false', function () {
+            var mainHostController = App.MainHostController.create({});
+            mainHostController.set('sortingAsc', false);
+            expect(mainHostController.get('sortClass')).to.equal('icon-arrow-up');
+        })
+    });
+
+
+    describe('#allChecked', function () {
+        it('should fill selectedhostsids array', function () {
+            var mainHostController = App.MainHostController.create();
+            mainHostController.set('allChecked', false);
+            expect(mainHostController.get('selectedHostsIds').length).to.equal(0);
+            mainHostController.set('allChecked', true);
+            expect(!!(mainHostController.get('selectedHostsIds').length)).to.equal(true);
+        })
+    });
+
+
+});

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/test/utils/form_field_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/test/utils/form_field_test.js?rev=1393847&r1=1393846&r2=1393847&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/test/utils/form_field_test.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/test/utils/form_field_test.js Thu Oct
 4 00:12:18 2012
@@ -1,164 +1,164 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-require('models/form');
-
-
-/*
- * formField.isValid property doesn't update correctly, so I have to work with errorMessage
property
- */
-describe('App.FormField', function () {
-
-  describe('#validate()', function () {
-    /*DIGITS TYPE*/
-    it('123456789 is correct digits', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'digits');
-      formField.set('value', 123456789);
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('"a33bc" is incorrect digits', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'digits');
-      formField.set('value', 'a33bc');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    /*DIGITS TYPE END*/
-    /*NUMBER TYPE*/
-    it('+1234 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '+1234');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('-1234 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '-1234');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('-1.23.6 is incorrect number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '-1.23.6');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    it('+1.6 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', +1.6);
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('-1.6 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', -1.6);
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('1.6 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', 1.6);
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('-.356 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '-.356');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('+.356 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '+.356');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('-1. is incorrect number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '-1.');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    it('+1. is incorrect number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '+1.');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    it('1. is incorrect number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '1.');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    it('-1,23,6 is incorrect number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '-1,23,6');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    it('-1234567890 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '-1234567890');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('+1234567890 is correct number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '+1234567890');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(true);
-    })
-    it('123eed is incorrect number', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'number');
-      formField.set('value', '123eed');
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    /*NUMBER TYPE END*/
-    /*REQUIRE*/
-    it('Required field shouldn\'t be empty', function () {
-      var formField = App.FormField.create();
-      formField.set('displayType', 'string');
-      formField.set('value', '');
-      formField.set('isRequired', true);
-      formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
-    })
-    /*REQUIRE END*/
-
-  })
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('models/form');
+
+
+/*
+ * formField.isValid property doesn't update correctly, so I have to work with errorMessage
property
+ */
+describe('App.FormField', function () {
+
+  describe('#validate()', function () {
+    /*DIGITS TYPE*/
+    it('123456789 is correct digits', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'digits');
+      formField.set('value', 123456789);
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('"a33bc" is incorrect digits', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'digits');
+      formField.set('value', 'a33bc');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    /*DIGITS TYPE END*/
+    /*NUMBER TYPE*/
+    it('+1234 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '+1234');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('-1234 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '-1234');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('-1.23.6 is incorrect number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '-1.23.6');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    it('+1.6 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', +1.6);
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('-1.6 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', -1.6);
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('1.6 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', 1.6);
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('-.356 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '-.356');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('+.356 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '+.356');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('-1. is incorrect number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '-1.');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    it('+1. is incorrect number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '+1.');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    it('1. is incorrect number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '1.');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    it('-1,23,6 is incorrect number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '-1,23,6');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    it('-1234567890 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '-1234567890');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('+1234567890 is correct number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '+1234567890');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(true);
+    })
+    it('123eed is incorrect number', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'number');
+      formField.set('value', '123eed');
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    /*NUMBER TYPE END*/
+    /*REQUIRE*/
+    it('Required field shouldn\'t be empty', function () {
+      var formField = App.FormField.create();
+      formField.set('displayType', 'string');
+      formField.set('value', '');
+      formField.set('isRequired', true);
+      formField.validate();
+      expect(formField.get('errorMessage') === '').to.equal(false);
+    })
+    /*REQUIRE END*/
+
+  })
 })
\ No newline at end of file



Mime
View raw message