Permalink
Browse files

added test for textarea

  • Loading branch information...
1 parent 4f36379 commit d78c551a0aec54ac4aadab1010deff53fce388cb @jamesstrate jamesstrate committed Mar 27, 2013
View
@@ -12,7 +12,7 @@ $(document).ready(function() {
});
- test("withDataBinding and labelContent", function() {
+ test("withDataBinding", function() {
var coffee = new Backbone.Model({
roaster: 'Counter Culture',
name: 'Baroida',
View
@@ -33,13 +33,18 @@
<script src='../src/js/text_field.js'></script>
<script src='../src/js/time_picker.js'></script>
<script src='../src/js/input_event.js'></script>
+ <script src="vendor/jquery.simulate.js"></script>
+ <script src="vendor/bililiteRange.js"></script>
+ <script src="vendor/jquery.simulate.ext.js"></script>
+ <script src="vendor/jquery.simulate.key-sequence.js"></script>
<script src="button.js"></script>
<script src="calendar.js"></script>
<script src="checkbox.js"></script>
<script src="pulldown.js"></script>
<script src="date_picker.js"></script>
<script src="link.js"></script>
+ <script src="text_area.js"></script>
<link rel='stylesheet' type='text/css' href='../src/css/button.css'>
<link rel='stylesheet' type='text/css' href='../src/css/calendar.css'>
View
@@ -0,0 +1,94 @@
+$(document).ready(function() {
+
+ module("Backbone.UI.TextArea");
+
+ test("withoutDataBinding", function() {
+ var textarea = new Backbone.UI.TextArea({
+ content : 'foo'
+ }).render();
+
+ var text = $(textarea.el).find('textarea').val();
+ equal(text, 'foo');
+
+ });
+
+ test("withDataBinding and labelContent", function() {
+ expect(3);
+ var coffee = new Backbone.Model({
+ roaster: 'Counter Culture',
+ name: 'Baroida',
+ roastedOn: new Date(2012, 2, 28, 6, 30),
+ acidic: true
+ });
+
+ var textarea = new Backbone.UI.TextArea({
+ model : coffee,
+ content : 'roaster'
+ }).render();
+
+ // text area content should have changed
+ var text = $(textarea.el).find('textarea').val();
+ equal(text, 'Counter Culture');
+
+ // update our model
+ coffee.set({
+ roaster : 'La Colombe'
+ });
+
+ // text should have changed
+ text = $(textarea.el).find('textarea').val();
+ equal(text, 'La Colombe');
+
+ //type in text area and check if model updates
+ $(textarea.el).find('textarea').simulate("key-sequence", {sequence: "a"});
+ stop();
+ setTimeout(function(){
+ equal(coffee.get('roaster'),'aLa Colombe');
+ start();
+ },1000);
+
+ });
+
+ test("disabled", function() {
+
+ var coffee = new Backbone.Model({
+ roaster: 'Counter Culture',
+ name: 'Baroida',
+ roastedOn: new Date(2012, 2, 28, 6, 30),
+ acidic: true
+ });
+
+ var textarea = new Backbone.UI.TextArea({
+ model : coffee,
+ content : 'roaster',
+ disabled : true
+ }).render();
+
+ //check if text area has disabled class
+ ok($(textarea.el).hasClass('disabled'));
+ //check if textare is disabled
+ ok($(textarea.el).find('textarea').is(":disabled"));
+
+ });
+
+ test("textAreaId", function() {
+
+ var coffee = new Backbone.Model({
+ roaster: 'Zafiro Anejo',
+ name: 'Baroida',
+ roastedOn: new Date(2012, 2, 28, 6, 30),
+ acidic: true
+ });
+
+ var textarea = new Backbone.UI.TextArea({
+ model : coffee,
+ content : 'roaster',
+ textAreaId : 'textArea1'
+ }).render();
+
+ //check value based on id
+ equal($(textarea.el).find('#textArea1').val(),'Zafiro Anejo');
+
+ });
+
+});
Oops, something went wrong.

0 comments on commit d78c551

Please sign in to comment.