Sha256: d865264f9c292ed3c828682e269c2a531c8655d4bce6df154dfe6c57d7d5825d
Contents?: true
Size: 1.97 KB
Versions: 7
Compression:
Stored size: 1.97 KB
Contents
// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2011 Strobe 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
7 entries across 7 versions & 2 rubygems