-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ios): setting TextField.value to wrong type triggers change event (…
…#11778) Fixes TIMOB-18256
- Loading branch information
1 parent
9823b0d
commit e06f9b5
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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 titanium, mocha */ | ||
/* eslint no-unused-expressions: "off" */ | ||
'use strict'; | ||
var should = require('./utilities/assertions'), | ||
utilities = require('./utilities/utilities'); | ||
|
||
describe('Titanium.UI.TextField', function () { | ||
var win; | ||
|
||
afterEach(function (done) { | ||
if (win) { | ||
// If `win` is already closed, we're done. | ||
let t = setTimeout(function () { | ||
if (win) { | ||
win = null; | ||
done(); | ||
} | ||
}, 3000); | ||
|
||
win.addEventListener('close', function listener () { | ||
clearTimeout(t); | ||
|
||
if (win) { | ||
win.removeEventListener('close', listener); | ||
} | ||
win = null; | ||
done(); | ||
}); | ||
win.close(); | ||
} else { | ||
win = null; | ||
done(); | ||
} | ||
}); | ||
|
||
// TextField should not receive change event after setting value. | ||
it.ios('change event should not fire after setting textField value', function (finish) { | ||
var textField; | ||
this.timeout(5000); | ||
|
||
win = Ti.UI.createWindow(); | ||
textField = Ti.UI.createTextField({ | ||
value: 123 | ||
}); | ||
textField.addEventListener('change', function () { | ||
// This should never happen. | ||
finish(new Error('TextField wrongly received change on setting value.')); | ||
}); | ||
win.add(textField); | ||
win.addEventListener('postlayout', function listener () { | ||
win.removeEventListener('postlayout', listener); | ||
// If we made it this far, assume TextField did not receive change. | ||
finish(); | ||
}); | ||
win.open(); | ||
}); | ||
}); |