Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 9 commits into from
Dec 19, 2018
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();
});

});