-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
390 additions
and
0 deletions.
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,42 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
|
||
<title>vaadin-number-field Basic Examples</title> | ||
|
||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="../../iron-form/iron-form.html"> | ||
<link rel="import" href="common.html"> | ||
</head> | ||
|
||
<body unresolved> | ||
<div class="vertical-section-container centered"> | ||
<demo-navigation></demo-navigation> | ||
<h3>Number Field</h3> | ||
<demo-snippet> | ||
<template> | ||
<vaadin-number-field></vaadin-number-field> | ||
</template> | ||
</demo-snippet> | ||
|
||
<h3>Number Field with controls</h3> | ||
<demo-snippet> | ||
<template> | ||
<vaadin-number-field has-controls></vaadin-number-field> | ||
</template> | ||
</demo-snippet> | ||
|
||
<h3>Number Field with value limits</h3> | ||
<demo-snippet> | ||
<template> | ||
<vaadin-number-field value="1" min="1" max="10" has-controls></vaadin-number-field> | ||
</template> | ||
</demo-snippet> | ||
</div> | ||
</body> | ||
|
||
</html> |
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,112 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-number-field tests</title> | ||
<script src="../../web-component-tester/browser.js"></script> | ||
<link rel="import" href="../vaadin-number-field.html"> | ||
<link rel="import" href="../../iron-form/iron-form.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="default"> | ||
<template> | ||
<vaadin-number-field></vaadin-number-field> | ||
</template> | ||
</test-fixture> | ||
|
||
<script> | ||
describe('number-field', function() { | ||
var numberField, input, decreaseButton, increaseButton; | ||
|
||
beforeEach(function() { | ||
numberField = fixture('default'); | ||
input = numberField.$.input; | ||
decreaseButton = numberField.root.querySelector('[part=decrease-button]'); | ||
increaseButton = numberField.root.querySelector('[part=increase-button]'); | ||
}); | ||
|
||
describe('native', function() { | ||
|
||
it('should have [type=number]', function() { | ||
expect(input.type).to.equal('number'); | ||
}); | ||
|
||
it('should have hidden controls', function() { | ||
expect(decreaseButton.hidden).to.be.true; | ||
expect(increaseButton.hidden).to.be.true; | ||
}); | ||
|
||
['min', 'max'].forEach(function(attr) { | ||
it('should set numeric attribute ' + attr, function() { | ||
var value = 5; | ||
numberField[attr] = value; | ||
var attrval = input.getAttribute(attr); | ||
|
||
expect(attrval).to.be.equal(String(value)); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('value control buttons', function() { | ||
it('should have value controls when hasControls is set to true', function() { | ||
expect(decreaseButton.hidden).to.be.true; | ||
expect(increaseButton.hidden).to.be.true; | ||
|
||
numberField.hasControls = true; | ||
|
||
expect(decreaseButton.hidden).to.be.false; | ||
expect(increaseButton.hidden).to.be.false; | ||
}); | ||
|
||
it('should increase value by 1 when increaseButton is clicked', function() { | ||
numberField.value = 0; | ||
|
||
increaseButton.click(); | ||
|
||
expect(numberField.value).to.be.equal(1); | ||
}); | ||
|
||
it('should decrease value by 1 when increaseButton is clicked', function() { | ||
numberField.value = 0; | ||
|
||
decreaseButton.click(); | ||
|
||
expect(numberField.value).to.be.equal(-1); | ||
}); | ||
|
||
it('should not increase value when increaseButton is clicked and max value is reached', function() { | ||
numberField.value = 10; | ||
numberField.max = 10; | ||
|
||
increaseButton.click(); | ||
|
||
expect(numberField.value).to.be.equal(10); | ||
}); | ||
|
||
it('should not decrease value when decreaseButton is clicked and min value is reached', function() { | ||
numberField.value = 1; | ||
numberField.min = 1; | ||
|
||
decreaseButton.click(); | ||
|
||
expect(numberField.value).to.be.equal(1); | ||
}); | ||
|
||
it('should not change value when number field is disabled and controls are clicked', function() { | ||
numberField.disabled = true; | ||
numberField.value = 0; | ||
|
||
increaseButton.click(); | ||
expect(numberField.value).to.be.equal(0); | ||
|
||
decreaseButton.click(); | ||
expect(numberField.value).to.be.equal(0); | ||
}); | ||
}); | ||
|
||
}); | ||
</script> | ||
</body> | ||
</html> |
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,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head lang="en"> | ||
<meta charset="UTF-8"> | ||
<title></title> | ||
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<link href="../../vaadin-number-field.html" rel="import"> | ||
<link href="./common.html" rel="import"> | ||
</head> | ||
|
||
<body> | ||
<fieldset id="number-field"> | ||
<p> | ||
<vaadin-number-field placeholder="Number"></vaadin-number-field> | ||
<p> | ||
<vaadin-number-field value="10"></vaadin-number-field> | ||
<p> | ||
<vaadin-number-field has-controls></vaadin-number-field> | ||
<p> | ||
<vaadin-number-field value="10" has-controls></vaadin-number-field> | ||
</fieldset> | ||
</body> | ||
|
||
</html> |
Binary file added
BIN
+2.54 KB
test/visual/screens/vaadin-text-field/number-field/number-field/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.09 KB
test/visual/screens/vaadin-text-field/number-field/number-field/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.05 KB
test/visual/screens/vaadin-text-field/number-field/number-field/firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.91 KB
test/visual/screens/vaadin-text-field/number-field/number-field/ie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.