Skip to content

Commit

Permalink
fix(ios) : Convert property ‘value’ to string inside hasText function (
Browse files Browse the repository at this point in the history
…#10521)

* fix(ios) : Convert property ‘value’ to string inside hasText function

* fix(ios) : Unit test added

* fix(ios): Indentation fixed

* fix(ios) : Indentation fixed

* fix(ios): Unit test updated
  • Loading branch information
vijaysingh-axway authored and ssjsamir committed Dec 19, 2018
1 parent 23c4929 commit 3f1c9c2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iphone/Classes/TiUITextWidgetProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (NSNumber *)hasText:(id)unused
YES);
return [NSNumber numberWithBool:viewHasText];
} else {
NSString *value = [self valueForKey:@"value"];
NSString *value = [TiUtils stringValue:[self valueForKey:@"value"]];
BOOL viewHasText = value != nil && [value length] > 0;
return [NSNumber numberWithBool:viewHasText];
}
Expand Down
45 changes: 45 additions & 0 deletions tests/Resources/ti.ui.textfield.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* global Ti, Titanium */
/* eslint no-unused-expressions: "off" */
'use strict';
var should = require('./utilities/assertions');

describe('Titanium.UI.TextField', function () {
var win;

afterEach(function () {
if (win) {
win.close();
}
win = null;
});

it.ios('hasText', function () {
win = Ti.UI.createWindow();
var textFieldA = Ti.UI.createTextField({
top: '60dip',
value: 0
});

win.add(textFieldA);

var textFieldB = Ti.UI.createTextField({
top: '120dip',
value: 0
});

win.add(textFieldB);

should(textFieldA.hasText()).be.true;
should(textFieldB.hasText()).be.true;

win.open();
});

});

0 comments on commit 3f1c9c2

Please sign in to comment.