Sha256: 454b8bae1b1c633c3948ff5ed5c59634534c7f149ffcf39d171c5e713e1a9ed0

Contents?: true

Size: 1.98 KB

Versions: 5

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:   Licensed 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

5 entries across 5 versions & 1 rubygems

Version Path
sproutcore-1.4.4-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.4 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.3.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.3-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
sproutcore-1.4.3 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js