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

        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("SCV55,SCV1453|SCV1390,SCV1391,SCV1394,SCV1395- Display the nomenclature in the day view of the calendar by default");
        test('SCV1441 - Validate the nomenclature in the calendar',
            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 () {
                    afterElementLoad($("#inner-content p:contains('Please select a Service/Specialty and Clinic to view availability.')"), function () {
                        ok($("#inner-content p:contains('Please select a Service/Specialty and Clinic to view availability.')")
                                .text(),
                            'Select Service/Specialty and Clinic to display calendar');
                    });

                    $('#patient-search .ui-input-clear').trigger('tap');

                    // 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(3)
                        .trigger('click');
                    return 500;
                }, function () {
                    // Click View Availability to display the
                    // calendar
                    $("#appointment-button a").trigger('tap');
                    afterElementLoad($("#calendar"), function () {
                        ok($("#calendar")
                                .is(':visible'),
                            'Calendar is visible');
                    });

                }, function () {
                    $('.fc-button-next').trigger('click');

                    ok($('td').hasClass('available'),
                        'Appointment slot available');


                    //Click the available slot and validate the book appointment dialog
                    $("#calendar").find('.available').eq(0).trigger('click');
                    return 500;
                }, function () {
                    //Day view is displayed
                    equal($("#calendar").find('button').eq(5).hasClass('fc-state-active'), true, 'Day view');

                    //Default view of nomenclature is ON
                    equal($("#inner-content").find('section').eq(1).find('a').eq(0).attr('aria-valuenow'), 'on', 'Default value is ON');

                    equal($(".legend-key").text(), 'CLINIC NAME (Overbooks allowed per day)', 'Overbook key is visible');

                    equal($(".legend-key").text(), $("#legend > div").eq(0).attr('title'), 'Title attribute of clinic legend matches overbook key');

                    //Legend shows the number of overbooks allowed
                    equal($("#legend div:nth-child(2)").attr('data-overbooks'), '(0)', 'Number of overbooks');

                    //Different nomenclature in the day view
                    equal($("#calendar").find('button').eq(32).attr('data-status'), 'No Availability', 'Slot that is not available');
                    equal($("#calendar").find('button').eq(22).attr('data-status'), 'A', 'Number of overbooks');
                    equal($("#calendar").find('button').eq(29).attr('data-status'), '*', 'Number of superbooks');

                });


            });
    });