mirror of https://github.com/sveltejs/svelte
parent
03df401856
commit
8432950f53
@ -0,0 +1,63 @@
|
|||||||
|
const SEP_2019_INPUT_VALUE = '2019-09';
|
||||||
|
const SEP_2019_DATE_VALUE = new Date(SEP_2019_INPUT_VALUE);
|
||||||
|
|
||||||
|
const OCT_2019_INPUT_VALUE = '2019-10';
|
||||||
|
const OCT_2019_DATE_VALUE = new Date(OCT_2019_INPUT_VALUE);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
month: SEP_2019_DATE_VALUE
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<input type=month>
|
||||||
|
<p>[object Date] ${SEP_2019_DATE_VALUE}</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
ssrHtml: `
|
||||||
|
<input type=month value='${SEP_2019_INPUT_VALUE}'>
|
||||||
|
<p>[object Date] ${SEP_2019_DATE_VALUE}</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const input = target.querySelector('input');
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// assert.equal(input.value, SEP_2019_INPUT_VALUE);
|
||||||
|
assert.equal(component.month.toString(), SEP_2019_DATE_VALUE.toString());
|
||||||
|
|
||||||
|
const event = new window.Event('input');
|
||||||
|
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// input.value = OCT_2019_INPUT_VALUE;
|
||||||
|
input.valueAsDate = OCT_2019_DATE_VALUE;
|
||||||
|
await input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.month.toString(), OCT_2019_DATE_VALUE.toString());
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='month'>
|
||||||
|
<p>[object Date] ${OCT_2019_DATE_VALUE}</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.month = SEP_2019_DATE_VALUE;
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// assert.equal(input.value, SEP_2019_INPUT_VALUE);
|
||||||
|
assert.equal(input.valueAsDate.toString(), SEP_2019_DATE_VALUE.toString());
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='month'>
|
||||||
|
<p>[object Date] ${SEP_2019_DATE_VALUE}</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// empty string should be treated as undefined
|
||||||
|
// input.value = '';
|
||||||
|
|
||||||
|
input.valueAsDate = null;
|
||||||
|
await input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.month, null);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='month'>
|
||||||
|
<p>[object Null] null</p>
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
export let month;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input type="month" bind:valueAsDate={month}>
|
||||||
|
<p>{Object.prototype.toString.call(month)} {month}</p>
|
@ -0,0 +1,48 @@
|
|||||||
|
const LUNCHTIME = new Date(1970, 0, 1, 12, 30);
|
||||||
|
const TEATIME = new Date(1970, 0, 1, 12, 30);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
time: LUNCHTIME
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<input type=time>
|
||||||
|
<p>[object Date] ${LUNCHTIME}</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
ssrHtml: `
|
||||||
|
<input type=time value='12:30'>
|
||||||
|
<p>[object Date] ${LUNCHTIME}</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const input = target.querySelector('input');
|
||||||
|
const event = new window.Event('input');
|
||||||
|
|
||||||
|
input.valueAsDate = TEATIME;
|
||||||
|
await input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.time.toString(), TEATIME.toString());
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='time'>
|
||||||
|
<p>[object Date] ${TEATIME}</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.time = LUNCHTIME;
|
||||||
|
assert.equal(input.valueAsDate.toString(), LUNCHTIME.toString());
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='time'>
|
||||||
|
<p>[object Date] ${LUNCHTIME}</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
input.valueAsDate = null;
|
||||||
|
await input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.time, null);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='time'>
|
||||||
|
<p>[object Null] null</p>
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
export let time;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input type="time" bind:valueAsDate={time}>
|
||||||
|
<p>{Object.prototype.toString.call(time)} {time}</p>
|
@ -0,0 +1,63 @@
|
|||||||
|
const SEP_W36_2019_INPUT_VALUE = '2019-W36';
|
||||||
|
const SEP_W36_2019_DATE_VALUE = new Date('2019-09-03');
|
||||||
|
|
||||||
|
const W41_2019_INPUT_VALUE = '2019-10-07';
|
||||||
|
const W41_2019_DATE_VALUE = new Date(W41_2019_INPUT_VALUE);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
week: SEP_W36_2019_DATE_VALUE
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<input type=week>
|
||||||
|
<p>[object Date] ${SEP_W36_2019_DATE_VALUE}</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
ssrHtml: `
|
||||||
|
<input type=week value='${SEP_W36_2019_INPUT_VALUE}'>
|
||||||
|
<p>[object Date] ${SEP_W36_2019_DATE_VALUE}</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const input = target.querySelector('input');
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// assert.equal(input.value, SEP_W36_2019_INPUT_VALUE);
|
||||||
|
assert.equal(component.week.toString(), SEP_W36_2019_DATE_VALUE.toString());
|
||||||
|
|
||||||
|
const event = new window.Event('input');
|
||||||
|
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// input.value = W41_2019_INPUT_VALUE;
|
||||||
|
input.valueAsDate = W41_2019_DATE_VALUE;
|
||||||
|
await input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.week.toString(), W41_2019_DATE_VALUE.toString());
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='week'>
|
||||||
|
<p>[object Date] ${W41_2019_DATE_VALUE}</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.week = SEP_W36_2019_DATE_VALUE;
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// assert.equal(input.value, SEP_W36_2019_INPUT_VALUE);
|
||||||
|
assert.equal(input.valueAsDate.toString(), SEP_W36_2019_DATE_VALUE.toString());
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='week'>
|
||||||
|
<p>[object Date] ${SEP_W36_2019_DATE_VALUE}</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
// https://github.com/jsdom/jsdom/issues/2658
|
||||||
|
// empty string should be treated as undefined
|
||||||
|
// input.value = '';
|
||||||
|
|
||||||
|
input.valueAsDate = null;
|
||||||
|
await input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.week, null);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<input type='week'>
|
||||||
|
<p>[object Null] null</p>
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
export let week;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input type="week" bind:valueAsDate={week}>
|
||||||
|
<p>{Object.prototype.toString.call(week)} {week}</p>
|
Loading…
Reference in new issue