react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / request / node_modules / tough-cookie / test / date_test.js
81146 views/*!1* Copyright (c) 2015, Salesforce.com, Inc.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions are met:6*7* 1. Redistributions of source code must retain the above copyright notice,8* this list of conditions and the following disclaimer.9*10* 2. Redistributions in binary form must reproduce the above copyright notice,11* this list of conditions and the following disclaimer in the documentation12* and/or other materials provided with the distribution.13*14* 3. Neither the name of Salesforce.com nor the names of its contributors may15* be used to endorse or promote products derived from this software without16* specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"19* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE22* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR23* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF24* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS25* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN26* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)27* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28* POSSIBILITY OF SUCH DAMAGE.29*/3031'use strict';32var vows = require('vows');33var assert = require('assert');34var tough = require('../lib/cookie');3536function dateVows(table) {37var theVows = {};38Object.keys(table).forEach(function (date) {39var expect = table[date];40theVows[date] = function () {41var got = tough.parseDate(date) ? 'valid' : 'invalid';42assert.equal(got, expect ? 'valid' : 'invalid');43};44});45return {"date parsing": theVows};46}4748vows49.describe('Date')50.addBatch(dateVows({51"Wed, 09 Jun 2021 10:18:14 GMT": true,52"Wed, 09 Jun 2021 22:18:14 GMT": true,53"Tue, 18 Oct 2011 07:42:42.123 GMT": true,54"18 Oct 2011 07:42:42 GMT": true,55"8 Oct 2011 7:42:42 GMT": true,56"8 Oct 2011 7:2:42 GMT": true,57"Oct 18 2011 07:42:42 GMT": true,58"Tue Oct 18 2011 07:05:03 GMT+0000 (GMT)": true,59"09 Jun 2021 10:18:14 GMT": true,60"99 Jix 3038 48:86:72 ZMT": false,61'01 Jan 1970 00:00:00 GMT': true,62'01 Jan 1600 00:00:00 GMT': false, // before 160163'01 Jan 1601 00:00:00 GMT': true,64'10 Feb 81 13:00:00 GMT': true, // implicit year65'Thu, 17-Apr-2014 02:12:29 GMT': true, // dashes66'Thu, 17-Apr-2014 02:12:29 UTC': true // dashes and UTC67}))68.addBatch({69"strict date parse of Thu, 01 Jan 1970 00:00:010 GMT": {70topic: function () {71return tough.parseDate('Thu, 01 Jan 1970 00:00:010 GMT', true) ? true : false;72},73"invalid": function (date) {74assert.equal(date, false);75}76}77})78.export(module);798081