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

Add missing NumberBox test #11769

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const PLACEHOLDER_CLASS = 'dx-placeholder';
const ACTIVE_STATE_CLASS = 'dx-state-active';
const CLEAR_BUTTON_CLASS = 'dx-clear-button-area';

const INVALID_MESSAGE_POPUP_CONTENT_SELECTOR = '.dx-invalid-message .dx-overlay-content';

QUnit.module('basics', {}, () => {
QUnit.test('markup init', function(assert) {
const element = $('#numberbox').dxNumberBox();
Expand Down Expand Up @@ -2019,7 +2021,19 @@ QUnit.module('number validation', {}, () => {

const instance = $numberBox.dxNumberBox('instance');

assert.equal($numberBox.find('.dx-invalid-message .dx-overlay-content').text(), instance.option('invalidValueMessage'), 'validation message is rendered');
assert.equal($numberBox.find(INVALID_MESSAGE_POPUP_CONTENT_SELECTOR).text(), instance.option('invalidValueMessage'), 'validation message is rendered');
ksercs marked this conversation as resolved.
Show resolved Hide resolved
});

QUnit.test('custom validation message can be changed at runtime', function(assert) {
const $numberBox = $('#numberbox').dxNumberBox({
value: 'abc'
});
const instance = $numberBox.dxNumberBox('instance');

instance.option('invalidValueMessage', 'test message');
instance.option('value', 'ab');

assert.strictEqual($numberBox.find(INVALID_MESSAGE_POPUP_CONTENT_SELECTOR).text(), 'test message', 'new validation message is applyed after the value change');
});

QUnit.test('the validation message should be shown if value is invalid after \'enter\' key was pressed', function(assert) {
Expand All @@ -2042,11 +2056,11 @@ QUnit.module('number validation', {}, () => {

keyboard.type('2');
keyboard.change();
assert.equal($numberBox.find('.dx-invalid-message .dx-overlay-content').text(), instance.option('validationError').message, 'validation message is rendered');
assert.equal($numberBox.find(INVALID_MESSAGE_POPUP_CONTENT_SELECTOR).text(), instance.option('validationError').message, 'validation message is rendered');

keyboard.press('enter');

assert.equal($numberBox.find('.dx-invalid-message .dx-overlay-content').text(), 'Value is not in range', 'validation message is not empty');
assert.equal($numberBox.find(INVALID_MESSAGE_POPUP_CONTENT_SELECTOR).text(), 'Value is not in range', 'validation message is not empty');
});

QUnit.test('onValueChanged should be fired after \'enter\' key was pressed', function(assert) {
Expand Down