diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index bd4c38cc4..5dab96928 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -45,9 +45,9 @@ allTests["COLOR"] = require("./color-tests"); allTests["DEPENDENCY-OBSERVABLE"] = require("./ui/dependency-observable-tests"); // allTests["BINDABLE"] = require("./ui/bindable-tests"); -// allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests"); +allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests"); allTests["XML-PARSER"] = require("./xml-parser-tests/xml-parser-tests"); -// allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests"); +allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests"); allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests"); allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests"); allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests"); diff --git a/tests/app/text/formatted-string-tests.ts b/tests/app/text/formatted-string-tests.ts index 9a89d00aa..f7d672bd4 100644 --- a/tests/app/text/formatted-string-tests.ts +++ b/tests/app/text/formatted-string-tests.ts @@ -1,17 +1,17 @@ // >> formatted-string-require -import * as formattedStringModule from "text/formatted-string"; -import * as spanModule from "text/span"; +import { FormattedString } from "text/formatted-string"; +import { Span } from "text/span"; // << formatted-string-require -import * as observable from "data/observable"; +import { Observable } from "data/observable"; +import { Label } from "ui/label"; import * as TKUnit from "../TKUnit"; -import * as LabelModule from "ui/label"; -export var test_FormattedString_RemovesEventListeners_for_spans = function () { +export function test_FormattedString_RemovesEventListeners_for_spans() { // >> formatted-string-set - var label = new LabelModule.Label(); - var formattedString = new formattedStringModule.FormattedString(); - var firstSpan = new spanModule.Span(); + const label = new Label(); + const formattedString = new FormattedString(); + const firstSpan = new Span(); firstSpan.fontSize = 15; firstSpan.text = "LoremIpsum"; @@ -19,37 +19,37 @@ export var test_FormattedString_RemovesEventListeners_for_spans = function () { label.formattedText = formattedString; // << formatted-string-set - TKUnit.assert(formattedString.spans.getItem(0).hasListeners(observable.Observable.propertyChangeEvent) === true, "Listener for spans collection change event is not attached!"); - var removedSpan = formattedString.spans.pop(); - TKUnit.assert(removedSpan.hasListeners(observable.Observable.propertyChangeEvent) === false, "Listener for spans collection change event is not removed!"); -} + TKUnit.assert(formattedString.spans.getItem(0).hasListeners(Observable.propertyChangeEvent) === true, "Listener for spans collection change event is not attached!"); + const removedSpan = formattedString.spans.pop(); + TKUnit.assert(removedSpan.hasListeners(Observable.propertyChangeEvent) === false, "Listener for spans collection change event is not removed!"); +}; -export var test_FormattedTextProperty_IsChanged_When_SpanIsAdded = function () { - var formattedString = new formattedStringModule.FormattedString(); - var formattedTextChanged = false; - formattedString.addEventListener(observable.Observable.propertyChangeEvent, () => { +export function test_FormattedTextProperty_IsChanged_When_SpanIsAdded() { + const formattedString = new FormattedString(); + let formattedTextChanged = false; + formattedString.addEventListener(Observable.propertyChangeEvent, () => { formattedTextChanged = true; }); - var firstSpan = new spanModule.Span(); + const firstSpan = new Span(); firstSpan.fontSize = 15; firstSpan.text = "LoremIpsum"; formattedString.spans.push(firstSpan); TKUnit.assertTrue(formattedTextChanged, "FormattedText property is not changed."); -} +}; -export var test_FormattedTextProperty_IsChanged_When_SpanIsChanged = function () { - var formattedString = new formattedStringModule.FormattedString(); - var expectedValue = 17; +export function test_FormattedTextProperty_IsChanged_When_SpanIsChanged() { + const formattedString = new FormattedString(); + const expectedValue = 17; - var firstSpan = new spanModule.Span(); + const firstSpan = new Span(); firstSpan.fontSize = 15; firstSpan.text = "LoremIpsum"; formattedString.spans.push(firstSpan); - var formattedTextChanged = false; - formattedString.addEventListener(observable.Observable.propertyChangeEvent, () => { + let formattedTextChanged = false; + formattedString.addEventListener(Observable.propertyChangeEvent, () => { formattedTextChanged = true; }); @@ -59,23 +59,23 @@ export var test_FormattedTextProperty_IsChanged_When_SpanIsChanged = function () TKUnit.assertTrue(formattedTextChanged, "FormattedText property is not changed."); TKUnit.assert(formattedString.spans.getItem(0).fontSize === expectedValue, "FormattedString internal span is not changed as expected"); -} +}; -export var test_FormattedTextProperty_DoNotCrash_When_KnownColorIsSetForForegroundColor = function () { - var formattedString = new formattedStringModule.FormattedString(); - var expectedValue1 = "red"; - var expectedValue2 = "blue"; +export function test_FormattedTextProperty_DoNotCrash_When_KnownColorIsSetForForegroundColor() { + const formattedString = new FormattedString(); + const expectedValue1 = "red"; + const expectedValue2 = "blue"; - var firstSpan = new spanModule.Span(); + const firstSpan = new Span(); firstSpan.foregroundColor = expectedValue1; firstSpan.text = "LoremIpsum1"; formattedString.spans.push(firstSpan); - var secondSpan = new spanModule.Span(); + const secondSpan = new Span(); secondSpan.backgroundColor = expectedValue2; secondSpan.text = "LoremIpsum2"; formattedString.spans.push(secondSpan); TKUnit.assertEqual(formattedString.spans.getItem(0).foregroundColor.name, expectedValue1); TKUnit.assertEqual(formattedString.spans.getItem(1).backgroundColor.name, expectedValue2); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/tns-core-modules/ui/label/label.ios.ts b/tns-core-modules/ui/label/label.ios.ts index b4f31f244..e74ee8f09 100644 --- a/tns-core-modules/ui/label/label.ios.ts +++ b/tns-core-modules/ui/label/label.ios.ts @@ -20,25 +20,25 @@ enum FixedSize { const zeroLength: Length = { value: 0, unit: "px" -} +}; export class Label extends TextBase implements LabelDefinition { - private _ios: TNSLabel; + public nativeView: TNSLabel; private _fixedSize: FixedSize; constructor() { super(); - this._ios = TNSLabel.new(); - this._ios.userInteractionEnabled = true; + this.nativeView = TNSLabel.new(); + this.nativeView.userInteractionEnabled = true; } get ios(): TNSLabel { - return this._ios; + return this.nativeView; } get _nativeView(): TNSLabel { - return this._ios; + return this.nativeView; } get textWrap(): boolean { @@ -106,7 +106,7 @@ export class Label extends TextBase implements LabelDefinition { } set [whiteSpaceProperty.native](value: WhiteSpace) { let nativeView = this.nativeView; - switch(value){ + switch (value) { case WhiteSpace.NORMAL: nativeView.lineBreakMode = NSLineBreakMode.ByWordWrapping; nativeView.numberOfLines = 0; @@ -115,7 +115,7 @@ export class Label extends TextBase implements LabelDefinition { nativeView.lineBreakMode = NSLineBreakMode.ByTruncatingTail; nativeView.numberOfLines = 1; break; - default: + default: throw new Error(`Invalid whitespace value: ${value}. Valid values are: "${WhiteSpace.NORMAL}", "${WhiteSpace.NO_WRAP}".`); } }