From 557d54b3deccd61bc199f11ffb231842a8f5c7a3 Mon Sep 17 00:00:00 2001 From: gdi2290 Date: Thu, 14 May 2015 09:17:44 -0700 Subject: [PATCH] feat(facade): toUpperCase and toLowerCase --- modules/angular2/src/facade/lang.dart | 8 +++++++ modules/angular2/src/facade/lang.ts | 4 ++++ modules/angular2/test/facade/lang_spec.js | 27 ++++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/angular2/src/facade/lang.dart b/modules/angular2/src/facade/lang.dart index a797945ca4..b22a260c21 100644 --- a/modules/angular2/src/facade/lang.dart +++ b/modules/angular2/src/facade/lang.dart @@ -64,6 +64,14 @@ class StringWrapper { return s.replaceAll(from, replace); } + static String toUpperCase(String s) { + return s.toUpperCase(); + } + + static String toLowerCase(String s) { + return s.toLowerCase(); + } + static startsWith(String s, String start) { return s.startsWith(start); } diff --git a/modules/angular2/src/facade/lang.ts b/modules/angular2/src/facade/lang.ts index 3a02ddd99c..cf1b1f93ca 100644 --- a/modules/angular2/src/facade/lang.ts +++ b/modules/angular2/src/facade/lang.ts @@ -104,6 +104,10 @@ export class StringWrapper { return s.replace(from, replace); } + static toUpperCase(s: string): string { return s.toUpperCase(); } + + static toLowerCase(s: string): string { return s.toLowerCase(); } + static startsWith(s: string, start: string) { return s.startsWith(start); } static substring(s: string, start: int, end: int = null) { diff --git a/modules/angular2/test/facade/lang_spec.js b/modules/angular2/test/facade/lang_spec.js index 29ab544032..e36fba2391 100644 --- a/modules/angular2/test/facade/lang_spec.js +++ b/modules/angular2/test/facade/lang_spec.js @@ -1,7 +1,7 @@ import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {isPresent, RegExpWrapper, RegExpMatcherWrapper, CONST_EXPR} from 'angular2/src/facade/lang'; +import {isPresent, RegExpWrapper, RegExpMatcherWrapper, StringWrapper, CONST_EXPR} from 'angular2/src/facade/lang'; export function main() { describe('RegExp', () => { @@ -20,13 +20,34 @@ export function main() { expect(indexes).toEqual([1, 4, 8, 9]); }) - }); + }); describe('const', () => { it('should support const expressions both in TS and Dart', () => { const numbers = CONST_EXPR([1, 2, 3]); expect(numbers).toEqual([1, 2, 3]); }) - }); + }); + + describe('String', () => { + var upper, lower; + + beforeEach(() => { + upper = 'SOMETHING' + lower = 'something'; + }); + + it('should upper case a string', () => { + var str = StringWrapper.toUpperCase(lower); + + expect(str).toEqual(upper); + }); + + it('should lower case a string', () => { + var str = StringWrapper.toLowerCase(upper); + + expect(str).toEqual(lower); + }); + }); }