Skip to content

Commit 7ffb3e8

Browse files
committed
ACP2E-3392: Broken validation for “Maximum Qty Allowed in Shopping Cart”
- Initial solution with test
1 parent 53865cc commit 7ffb3e8

File tree

3 files changed

+29
-3
lines changed
  • app/code/Magento
  • dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation

3 files changed

+29
-3
lines changed

app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2016 Adobe
5+
* All rights reserved.
66
*/
77
-->
88
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
5+
/* eslint-disable no-useless-escape */
6+
// jscs:disable no-useless-escape
67
/**
78
* @api
89
*/

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ define([
9494
expect(rules['validate-number'].handler(value)).toBe(false);
9595
});
9696
});
97+
describe('"validate-nonempty-number-greater-than-zero" method', function () {
98+
it('Check on empty value', function () {
99+
var value = '';
100+
101+
expect(rules['validate-nonempty-number-greater-than-zero'].handler(value)).toBe(false);
102+
});
103+
104+
it('Check on integer', function () {
105+
var value = '125';
106+
107+
expect(rules['validate-nonempty-number-greater-than-zero'].handler(value)).toBe(true);
108+
});
109+
110+
it('Check on zero', function () {
111+
var value = '0';
112+
113+
expect(rules['validate-nonempty-number-greater-than-zero'].handler(value)).toBe(false);
114+
});
115+
116+
it('Check on not a number', function () {
117+
var value = 'string';
118+
119+
expect(rules['validate-nonempty-number-greater-than-zero'].handler(value)).toBe(false);
120+
});
121+
});
97122
});
98123

99124
describe('validate-color', function () {

0 commit comments

Comments
 (0)