Sha256: f18b17a58b6740453cbd82d38c5f34eee056d353be87fa7ab97eaeaab82d97be

Contents?: true

Size: 1.73 KB

Versions: 11

Compression:

Stored size: 1.73 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
//            Portions ©2008-2010 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*global module test equals context */

var context = null;

module("SC.RenderContext#get", {
  setup: function() {
    context = SC.RenderContext();
  },
  
  teardown: function() {
    context = null;
  }
});

test("it should return strings array with space for top tag if no params passed and no strings pushed yet", function() {
  same(context.get(), [null]);
});

test("it should return full strings array if no params passed and no strings pushed yet", function() {
  context.push("line1");
  same(context.get(), [null, "line1"]);
});

test("it should return individual string if index passed that is within current length", function() {
  context.push("line1");
  equals(context.get(1), "line1");
});

test("it should return undefined if index passed that is outside of current range", function() {
  context.push("line1");
  equals(context.get(3), undefined);
});

// test this special case since the internal strings array is created lazily.
test("it should return undefined if index passed and no strings set yet", function() {
  equals(context.get(2), undefined);
});

test("it should return the value based on an index from the context offset of the context is chained", function() {
  context.push('line1', 'line2');
  var childContext = context.begin();
  childContext.push("NEXT");
  equals(childContext.get(1), "NEXT", 'gets child line');
}) ;

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sproutcore-1.4.4-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.4 lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.3.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.3-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.3 lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.2-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.2 lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.1-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.0-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js
sproutcore-1.4.0 lib/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js