define(
    [ 'jQuery', 'asyncSeries', 'testUtilities' ],
    function ($$, asyncSeries, utilities) {

        function patientSelect(name) {
            // This method is used by patient viewer to search and select a
            // patient before proceeding
            if (window.location.href.indexOf('scheduling-manager')) {
                var e = $.Event("keypress"), $input = $("#patient-search-input");
                e.which = e.keyCode = 13;
                $input.val(name).trigger(e);

            }
        }

        module("SCV94 |SCV23- Options for viewing the calendar/list views include 1 Day, 1 week, and 1 Month (default) time periods");
        test('SCV297 - Validate user can navigate calendar by month, week or by day upto 12 months from current date', function () {
            ok(true, "Tests are running.");

            $(window).load(function () {
                asyncSeries(function () {
                    afterElementLoad($("#calendar-specialty-input"), function () {
                        ok($('#left-navigation').is(':visible'),
                            "Header is visible");
                    });

                    // Then I can see the header info
                    ok($('#left-navigation:contains("Open Menu")').text(),
                        "Then I can see the header bar");
                    return 1500;
                }, function () {
                    $(window).load(function () {

                        ok($("#inner-content").find('p').text(),
                            'Please select a Service/Specialty and Clinic to view availability.');

                        // Select Service/Specialty and Clinic to
                        // show calendar
                        $("#calendar-specialty-input").val('Medicine')
                            .keyup();
                        $("#calendar-specialty li:nth-child(6) a")
                            .trigger('tap');

                        $('#calendar-clinic-button')
                            .trigger('click');

                        // Select Clinic
                        $("#calendar-clinic-menu label").eq(0)
                            .trigger('click');

                    });
                }, function () {
                    // Click View Availability to display the
                    // calendar
                    $(window).load(function () {

                        $("#appointment-button a").trigger('tap');
                        afterElementLoad($("#calendar"),
                            function () {
                                ok($("#calendar")
                                        .is(':visible'),
                                    'Calendar is visible');
                            });

                        $('.fc-button-next').trigger('click');
                        ok($('td').hasClass('available'),
                            'Appointment slot available');

                        //Validate navigation by month, week and day view
                        //Default is month view
                        equal($("#calendar").find('td').eq(2).find('button').eq(0).hasClass('fc-button-month'), true, 'Default month view');

                        //Click to navigate to week view
                        $("#calendar").find('td').eq(2).find('button').eq(1).trigger('click');
                        equal($("#calendar").find('td').eq(2).find('button').eq(1).hasClass('fc-button-agendaWeek'), true, 'Week view');

                        //Click to navigate to day view
                        $("#calendar").find('td').eq(2).find('button').eq(2).trigger('click');
                        equal($("#calendar").find('td').eq(2).find('button').eq(2).hasClass('fc-button-agendaDay'), true, 'Day view');

                    });
                });
            });
        });
    });
