blob: 77a1c0e96ac4b5f2fbec0b166f1b182a16c2b4b5 [file] [log] [blame]
Tests for .valueAsNumber with <input type=week>.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS valueAsNumberFor("") is Number.NaN
PASS valueAsNumberFor("2007-W01") is Date.UTC(2007, 0, 1)
PASS valueAsNumberFor("2008-W01") is Date.UTC(2007, 11, 31)
PASS valueAsNumberFor("2003-W01") is Date.UTC(2002, 11, 30)
PASS valueAsNumberFor("2004-W01") is Date.UTC(2003, 11, 29, 0, 0, 0, 0)
PASS valueAsNumberFor("2010-W01") is Date.UTC(2010, 0, 4)
PASS valueAsNumberFor("2005-W01") is Date.UTC(2005, 0, 3)
PASS valueAsNumberFor("2006-W01") is Date.UTC(2006, 0, 2)
Various January 1st:
PASS setValueAsNumberAndGetValue(2007, 0, 1) is "2007-W01"
PASS setValueAsNumberAndGetValue(2008, 0, 1) is "2008-W01"
PASS setValueAsNumberAndGetValue(2003, 0, 1) is "2003-W01"
PASS setValueAsNumberAndGetValue(2004, 0, 1) is "2004-W01"
PASS setValueAsNumberAndGetValue(2010, 0, 1) is "2009-W53"
PASS setValueAsNumberAndGetValue(2005, 0, 1) is "2004-W53"
PASS setValueAsNumberAndGetValue(2006, 0, 1) is "2005-W52"
Normal cases:
PASS setValueAsNumberAndGetValue(2010, 0, 3) is "2009-W53"
PASS setValueAsNumberAndGetValue(2010, 0, 4) is "2010-W01"
PASS setValueAsNumberAndGetValue(2010, 0, 10) is "2010-W01"
PASS setValueAsNumberAndGetValue(2010, 0, 11) is "2010-W02"
PASS setValueAsNumberAndGetValue(2010, 0, 17) is "2010-W02"
PASS setValueAsNumberAndGetValue(2010, 11, 31) is "2010-W52"
Around the minimum/maximum values:
PASS setValueAsNumberAndGetValue(0, 11, 31) is ""
PASS setValueAsNumberAndGetValue(1, 0, 1) is "0001-W01"
PASS setValueAsNumberAndGetValue(275760, 8, 8) is "275760-W37"
PASS setValueAsNumberAndGetValue(275760, 8, 13) is "275760-W37"
Tests to set invalid values to valueAsNumber:
PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-W01"
PASS input.valueAsNumber = "foo" threw exception NotSupportedError: The operation is not supported..
PASS input.valueAsNumber = NaN threw exception NotSupportedError: The operation is not supported..
PASS input.valueAsNumber = Number.NaN threw exception NotSupportedError: The operation is not supported..
PASS input.valueAsNumber = Infinity threw exception NotSupportedError: The operation is not supported..
PASS input.valueAsNumber = Number.POSITIVE_INFINITY threw exception NotSupportedError: The operation is not supported..
PASS input.valueAsNumber = Number.NEGATIVE_INFINITY threw exception NotSupportedError: The operation is not supported..
PASS input.valueAsNumber = Date.UTC(275760, 8, 14) threw exception NotSupportedError: The operation is not supported..
PASS successfullyParsed is true
TEST COMPLETE