Sha256: 3d40c8943eb2ea30f3bb09b338e4a3a7c4c2d6f28bf9a37ce93e870f262d2a29

Contents?: true

Size: 1.92 KB

Versions: 5

Compression:

Stored size: 1.92 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2010 Apple Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
/*global module test equals context ok same */
var LocaleObject;
module('String.prototype.w()', {
  setup: function() {

    LocaleObject = SC.Locale.create({
      init: function(){
        sc_super();
        //hash of new languages
        var newLocales = { deflang: 'dl', empty: '' };

        //Added the new languages to the existing list of locales
        SC.Locale.addStrings(newLocales);
      }
    });
    this.currentLocale = LocaleObject;
  }
});

test("'one two three'.w() => ['one','two','three']", function() {
  same('one two three'.w(), ['one','two','three'], "should be equal");
});

test("'one    two    three'.w() with extra spaces between words => ['one','two','three']", function() {
  same('one    two    three'.w(), ['one','two','three'], "should be equal");
});

test("Trim ' spaces on both sides '", function() {
  same(' spaces on both sides '.trim(), 'spaces on both sides', "should be equal");
});

test("Trim ' spaces on both sides ' on left only", function() {
  same(' spaces on both sides '.trimLeft(), 'spaces on both sides ', "should be equal");
});

test("Trim ' spaces on both sides ' on right only", function() {
  same(' spaces on both sides '.trimRight(), ' spaces on both sides', "should be equal");
});

test("Localize a string", function() {
  //Based on the input passed it should return the default locale
  equals("en".loc(), "en") ;
  equals("jp".locWithDefault("Japanese"), "Japanese") ;
  equals('deflang'.loc(), "dl") ;
});

test("Localize a string even if localized version is empty", function() {
  equals("empty".loc(), "");
  equals("empty".locWithDefault("Empty"), "");
});

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/core_foundation/tests/mixins/string.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/amber/tests/mixins/string.js