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

test: make sure no initial validation happens (CP: 14) #205

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
"no-undef": 0,
"no-unused-vars": 0
Expand All @@ -7,10 +10,12 @@
"WCT": false,
"describe": false,
"beforeEach": false,
"afterEach": false,
"fixture": false,
"it": false,
"expect": false,
"gemini": false,
"sinon": false
"sinon": false,
"nextRender": false
}
}
14 changes: 14 additions & 0 deletions test/helpers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>

<head>
<link rel="import" href="../../polymer/polymer.html">
</head>
<body>
<script>
window.nextRender = (element) => {
return new Promise(resolve => {
Polymer.RenderStatus.afterNextRender(element, resolve);
});
};
</script>
</body>
3 changes: 2 additions & 1 deletion test/test-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ window.TimePickerElementSuites = [
'form-input.html',
'keyboard-navigation.html',
'styling.html',
'range-test.html'
'range-test.html',
'validation.html'
];
48 changes: 48 additions & 0 deletions test/validation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!doctype html>

<head>
<meta charset="UTF-8">
<title>vaadin-time-picker validation tests</title>
<script src='../../web-component-tester/browser.js'></script>
<script src='../../webcomponentsjs/webcomponents-lite.js'></script>
<link rel="import" href="../src/vaadin-time-picker.html">
<link rel="import" href="helpers.html">
</head>

<body>
<script>
describe('initial validation', () => {
let timePicker, validateSpy;

beforeEach(() => {
timePicker = document.createElement('vaadin-time-picker');
validateSpy = sinon.spy(timePicker, 'validate');
});

afterEach(() => {
timePicker.remove();
});

it('should not validate by default', async() => {
document.body.appendChild(timePicker);
await nextRender();
expect(validateSpy.called).to.be.false;
});

it('should not validate when the field has an initial value', async() => {
timePicker.value = '12:00';
document.body.appendChild(timePicker);
await nextRender();
expect(validateSpy.called).to.be.false;
});

it('should not validate when the field has an initial value and invalid', async() => {
timePicker.value = '12:00';
timePicker.invalid = true;
document.body.appendChild(timePicker);
await nextRender();
expect(validateSpy.called).to.be.false;
});
});
</script>
</body>