Sha256: 00aa0adcac487f419abd6a3d0c37e1bac6702203a3b4d3cf8fe05169f05a9e70

Contents?: true

Size: 1.98 KB

Versions: 6

Compression:

Stored size: 1.98 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
//            portions copyright @2009 Apple Inc.
// License:   Licened under MIT license (see license.js)
// ==========================================================================

/*global module test htmlbody ok equals same stop start */

(function() {
  var pane = SC.ControlTestPane.design()
  .add("with valid value", SC.View.extend(SC.Validatable), { 
    value: SC.Object.create({ data: 'here is some data' })
  })
  
  .add("with error value", SC.View.extend(SC.Validatable), { 
    value: SC.Error.create({ errorValue: 'bad data', message: 'Input is bad' })
  });
    
pane.show(); // add a test to show the test pane

pane.verifyInvalid = function(view, isInvalid) {
  var layer = view.$();
  if (isInvalid) {
    ok(layer.hasClass('invalid'), 'layer should have invalid class');
  }
  else {
    ok(!layer.hasClass('invalid'), 'layer should not have invalid class');
  }
};


// ..........................................................
// TEST INITIAL STATES
// 

module('SC.Validatable ui', pane.standardSetup());

test("with valid value", function() {
  var view = pane.view('with valid value');
  pane.verifyInvalid(view, NO);
});

test("with invalid value", function() {
  var view = pane.view('with error value');
  pane.verifyInvalid(view, YES);
});


// ..........................................................
// TEST CHANGING VIEWS
//

test("changing from invalid to valid", function() {
  var view = pane.view('with error value');
  
  SC.RunLoop.begin();
  view.set('value', 'not an SC.Error instance');
  SC.RunLoop.end();
  
  pane.verifyInvalid(view, NO);
});

test("changing from valid to invalid", function() {
  var view = pane.view('with valid value');
  
  SC.RunLoop.begin();
  view.set('value', SC.Error.create());
  SC.RunLoop.end();
  
  pane.verifyInvalid(view, YES);
});

})();

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sproutcore-1.4.2-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.2 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.1-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.0-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.0 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js