176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<html>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<head>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<title>Calendar Tests</title>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<script type="text/javascript" src="/build/yui/yui.js"></script>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich</head>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<body class="yui3-skin-sam">
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<h1>Calendar Tests</h1>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<p><input type="button" value="Run Tests" id="btnRun" disabled=true></p>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<div id="container"></div>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich<script type="text/javascript">
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich(function() {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich YUI({
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich base: "/build/",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich logInclude:{"TestRunner":true},
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich useConsole: true,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich allowRollup: false,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich }).use("console", "test", "dump", "calendar", "node-event-simulate", function(Y) {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Set up the page
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var ASSERT = Y.Assert,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich ARRAYASSERT = Y.ArrayAssert,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich btnRun = Y.one("#btnRun"),
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich myConsole = new Y.Console().render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich btnRun.set("disabled", false);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.on("click", function(){
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Test.Runner.run();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich }, btnRun);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var BasicCalendar = new Y.Test.Case({
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich name: "Basic Calendar Tests",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich setUp : function () {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var firstcontainer = "<div id='firstcontainer'></div>";
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var secondcontainer = "<div id='secondcontainer'></div>";
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one('#container').appendChild(Y.Node.create(firstcontainer));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one('#container').appendChild(Y.Node.create(secondcontainer));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar = null;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.secondcalendar = null;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich },
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich tearDown : function () {
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich delete this.firstcalendar;
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich delete this.secondcalendar;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one('#firstcontainer').remove();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one('#secondcontainer').remove();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich },
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich testBasicCalendar : function() {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var cfg = {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich contentBox: "#firstcontainer",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich date: new Date(2011,11,5)
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich };
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar = new Y.Calendar(cfg);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar.render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich //calendar is visible
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(this.firstcalendar.get('visible'), true);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich //calendar date is normalized correctly
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var calendarDate = this.firstcalendar.get("date");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(2011, calendarDate.getFullYear());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(11, calendarDate.getMonth());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(1, calendarDate.getDate());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Test that the first and last days of the month render correctly
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Test that showPreviousMonth and showNextMonth are false by default
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(false, this.firstcalendar.get("showPrevMonth"));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(false, this.firstcalendar.get("showNextMonth"));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich },
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich testPrevAndNextMonth : function () {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var cfg = {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich contentBox: "#firstcontainer",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich date: new Date(2011,11,5),
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich showPrevMonth: true,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich showNextMonth: true
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich };
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar = new Y.Calendar(cfg);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar.render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Test that showPreviousMonth and showNextMonth are true
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(true, this.firstcalendar.get("showPrevMonth"));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(true, this.firstcalendar.get("showNextMonth"));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Test that previous and next months are showing
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("27", Y.one("#firstcontainer").one(".calendar_col2.yui3-calendar-prevmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("28", Y.one("#firstcontainer").one(".calendar_col3.yui3-calendar-prevmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("29", Y.one("#firstcontainer").one(".calendar_col4.yui3-calendar-prevmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("30", Y.one("#firstcontainer").one(".calendar_col5.yui3-calendar-prevmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("1", Y.one("#firstcontainer").one(".calendar_col2.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("2", Y.one("#firstcontainer").one(".calendar_col3.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("3", Y.one("#firstcontainer").one(".calendar_col4.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("4", Y.one("#firstcontainer").one(".calendar_col5.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("5", Y.one("#firstcontainer").one(".calendar_col6.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("6", Y.one("#firstcontainer").one(".calendar_col7.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual("7", Y.one("#firstcontainer").one(".calendar_col8.yui3-calendar-nextmonth-day").getContent());
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich },
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich testTwoCalendars : function () {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var cfg1 = {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich contentBox: "#firstcontainer",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich date: new Date(2011,11,5),
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich showPrevMonth: true,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich showNextMonth: true
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich };
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var cfg2 = {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich contentBox: "#secondcontainer",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich date: new Date(2011,11,5),
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich showPrevMonth: true,
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich showNextMonth: true
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich };
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar = new Y.Calendar(cfg1);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar.render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.secondcalendar = new Y.Calendar(cfg2);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.secondcalendar.render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areNotEqual(this.firstcalendar.get("id"), this.secondcalendar.get("id"));
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areNotEqual(this.firstcalendar._calendarId, this.secondcalendar._calendarId);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich },
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich testCalendarClick : function() {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var cfg = {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich contentBox: "#firstcontainer",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich date: new Date(2011,11,5)
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich };
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar = new Y.Calendar(cfg);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar.render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Click on a specific calendar cell;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var calendarid = this.firstcalendar._calendarId;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one("#" + calendarid + "_pane_0_6_15").simulate("click");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich var currentDate = this.firstcalendar.get("selectedDates")[0];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getFullYear(), 2011);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getMonth(), 11);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getDate(), 15);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Click on a different calendar cell
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one("#" + calendarid + "_pane_0_8_31").simulate("click");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich currentDate = this.firstcalendar.get("selectedDates")[0];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getFullYear(), 2011);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getMonth(), 11);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getDate(), 31);
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Click to advance the month
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich Y.one(".yui3-calendarnav-nextmonth").simulate("click");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Click on a date in the new month
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one("#" + calendarid + "_pane_0_8_17").simulate("click");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich currentDate = this.firstcalendar.get("selectedDates")[0];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getFullYear(), 2012);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getMonth(), 0);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(currentDate.getDate(), 17);
ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2eAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich },
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich testCustomHeader : function() {
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich var cfg = {
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich contentBox: "#firstcontainer",
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich date: new Date(2011,11,5)
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich };
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich this.firstcalendar = new Y.Calendar(cfg);
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich this.firstcalendar.set("headerRenderer", function (curDate) {
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich var ydate = Y.DataType.Date,
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich output = ydate.format(curDate, {
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich format: "%m %Y"
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich });
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich return output;
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich });
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich this.firstcalendar.render();
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich var currentHeaderString = this.firstcalendar.get("contentBox").one(".yui3-calendar-header-label").get("text");
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich Y.Assert.areEqual("12 2011", currentHeaderString);
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich // Click to advance the month
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich Y.one(".yui3-calendarnav-nextmonth").simulate("click");
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich currentHeaderString = this.firstcalendar.get("contentBox").one(".yui3-calendar-header-label").get("text");
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich Y.Assert.areEqual("01 2012", currentHeaderString);
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich },
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich testMultiplePanes : function () {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var cfg = {
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich contentBox: "#firstcontainer",
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich date: new Date(2011,11,5),
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich selectionMode: "multiple"
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich };
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Set the content template to a two-pane template
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.TWO_PANE_TEMPLATE;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar = new Y.Calendar(cfg);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich this.firstcalendar.render();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Click on a date
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var calendarid = this.firstcalendar._calendarId;
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one("#" + calendarid + "_pane_0_6_29").simulate("click");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich // Shift-click another date
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.one("#" + calendarid + "_pane_1_7_2").simulate("click", {shiftKey: true});
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var date0 = this.firstcalendar.get("selectedDates")[0];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var date1 = this.firstcalendar.get("selectedDates")[1];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var date2 = this.firstcalendar.get("selectedDates")[2];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var date3 = this.firstcalendar.get("selectedDates")[3];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var date4 = this.firstcalendar.get("selectedDates")[4];
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date0.getFullYear(), 2011);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date0.getMonth(), 11);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date0.getDate(), 29);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date1.getFullYear(), 2011);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date1.getMonth(), 11);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date1.getDate(), 30);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date2.getFullYear(), 2011);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date2.getMonth(), 11);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date2.getDate(), 31);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date3.getFullYear(), 2012);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date3.getMonth(), 0);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date3.getDate(), 1);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date4.getFullYear(), 2012);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date4.getMonth(), 0);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Assert.areEqual(date4.getDate(), 2);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich }
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich });
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich var suite = new Y.Test.Suite({name:"Basic Calendar Test Suite"});
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich suite.add(BasicCalendar);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Test.Runner.setName("Calendar Test Runner");
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Test.Runner.add(suite);
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich Y.Test.Runner.run();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich });
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich})();
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich</script>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich</body>
176bb1f5c1bead550f24ffc878201352795c73adAllen Rabinovich</html>