Skip to content

Commit

Permalink
Add missing NumberBox test (#11769)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-kotov-dx authored Jan 30, 2020
1 parent 78c9808 commit d98dcc4
Showing 1 changed file with 17 additions and 3 deletions.
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');
});

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

0 comments on commit d98dcc4

Please sign in to comment.