<commit_before>var Global = require("./global.js");

describe("VisualScheduleCard", function() {
    before(function (done) {
        var render_id = 'test_visual_schedule';

        Global.Environment.init({
            render_id: render_id,
            scripts: [
                "myuw/static/js/visual_schedule.js",
                "myuw/static/js/card/schedule/visual.js",
                "myuw/static/js/card/schedule/final_panel.js",
                "myuw/static/js/card/schedule/sp_final.js"
            ],
            templates: [
                'myuw/templates/handlebars/visual_schedule.html',
                'myuw/templates/handlebars/card/schedule/visual.html',
                'myuw/templates/handlebars/card/schedule/visual_day.html',
                'myuw/templates/handlebars/card/schedule/final_day.html',
                'myuw/templates/handlebars/card/schedule/final_panel.html'
            ]
        });

        window.card_display_dates = {};
        VisualScheduleCard.dom_target = $('#' + render_id);
        done();
    });

    describe('card renders', function() {
        before(function (done) {
            Global.Environment.ajax_stub({
                '/api/v1/visual_schedule/current': 'api/v1/schedule/visual.json'
            });

            //handle the two card load events the VS fires for inst+stu schedules
            var has_loaded = false;
            $(window).on("myuw:card_load", function () {
                if(!has_loaded){
                    done();
                    has_loaded = true;
                }
            });

            VisualScheduleCard.term = 'current';
            VisualScheduleCard.render_init();
        });

        it('for netid eight', function () {
            var $schedule = VisualScheduleCard.dom_target.find('.visual-schedule');
            assert.equal($schedule.length, 1);
            assert.equal($schedule.find('> .five-day').length, 5);
            assert.equal($schedule.find('> .five-day').eq(0).find('.visual-course').length, 1);
            assert.equal($schedule.find('> .five-day').eq(4).find('.visual-course').length, 1);
        });
        after(function () {
            Global.Environment.ajax_stub_restore();
            VisualScheduleCard.dom_target.html("");
        });
    });

        describe('card hides', function() {
        before(function (done) {
            VisualScheduleCard.term = 'current';
            VisualScheduleCard.render_init();
            done();
        });

        it('for netid eight', function () {
            var $schedule = VisualScheduleCard.dom_target.find('.visual-schedule');
            assert.equal($schedule.length, 0);
        });
        after(function () {
            Global.Environment.ajax_stub_restore();
            VisualScheduleCard.dom_target.html("");
        });
    });

    //describe('_get_default_period', function() {
    //    it('should get the default period', function() {
    //        window.card_display_dates.comparison_date = "2017-06-05";
    //        var start = moment.utc("2017-06-01");
    //        var end = moment.utc("2017-06-12");
    //        var weeks = VisualScheduleCard._get_weeks_from_range([start, end]);
    //
    //        var default_period = VisualScheduleCard._get_default_period(null, weeks);
    //        assert.equal(default_period, "23")
    //    });
    //
    //    it('should default to first if today is outside of the schedule range', function() {
    //        window.card_display_dates.comparison_date = "2017-09-05";
    //        var start = moment.utc("2017-06-01");
    //        var end = moment.utc("2017-06-12");
    //        var weeks = VisualScheduleCard._get_weeks_from_range([start, end]);
    //
    //        var default_period = VisualScheduleCard._get_default_period(weeks, null);
    //        assert.equal(default_period, "22")
    //    });
    //});
});

<commit_msg>adding more cleanup pre-test<commit_after>var Global = require("./global.js");

describe("VisualScheduleCard", function() {
    before(function (done) {
        var render_id = 'test_visual_schedule';

        Global.Environment.init({
            render_id: render_id,
            scripts: [
                "myuw/static/js/visual_schedule.js",
                "myuw/static/js/card/schedule/visual.js",
                "myuw/static/js/card/schedule/final_panel.js",
                "myuw/static/js/card/schedule/sp_final.js"
            ],
            templates: [
                'myuw/templates/handlebars/visual_schedule.html',
                'myuw/templates/handlebars/card/schedule/visual.html',
                'myuw/templates/handlebars/card/schedule/visual_day.html',
                'myuw/templates/handlebars/card/schedule/final_day.html',
                'myuw/templates/handlebars/card/schedule/final_panel.html'
            ]
        });

        window.card_display_dates = {};
        VisualScheduleCard.dom_target = $('#' + render_id);
        done();
    });

    describe('card renders', function() {
        before(function (done) {
            Global.Environment.ajax_stub({
                '/api/v1/visual_schedule/current': 'api/v1/schedule/visual.json'
            });

            //handle the two card load events the VS fires for inst+stu schedules
            var has_loaded = false;
            $(window).on("myuw:card_load", function () {
                if(!has_loaded){
                    done();
                    has_loaded = true;
                }
            });

            VisualScheduleCard.term = 'current';
            VisualScheduleCard.render_init();
        });

        it('for netid eight', function () {
            var $schedule = VisualScheduleCard.dom_target.find('.visual-schedule');
            assert.equal($schedule.length, 1);
            assert.equal($schedule.find('> .five-day').length, 5);
            assert.equal($schedule.find('> .five-day').eq(0).find('.visual-course').length, 1);
            assert.equal($schedule.find('> .five-day').eq(4).find('.visual-course').length, 1);
        });
        after(function () {
            Global.Environment.ajax_stub_restore();
            VisualScheduleCard.dom_target.html("");
        });
    });

        describe('card hides', function() {
        before(function (done) {
            Global.Environment.ajax_stub_restore();
            VisualScheduleCard.dom_target.html("");
            VisualScheduleCard.term = 'current';
            VisualScheduleCard.render_init();
            done();
        });

        it('for netid eight', function () {
            var $schedule = VisualScheduleCard.dom_target.find('.visual-schedule');
            assert.equal($schedule.length, 0);
        });
        after(function () {
            Global.Environment.ajax_stub_restore();
            VisualScheduleCard.dom_target.html("");
        });
    });

    //describe('_get_default_period', function() {
    //    it('should get the default period', function() {
    //        window.card_display_dates.comparison_date = "2017-06-05";
    //        var start = moment.utc("2017-06-01");
    //        var end = moment.utc("2017-06-12");
    //        var weeks = VisualScheduleCard._get_weeks_from_range([start, end]);
    //
    //        var default_period = VisualScheduleCard._get_default_period(null, weeks);
    //        assert.equal(default_period, "23")
    //    });
    //
    //    it('should default to first if today is outside of the schedule range', function() {
    //        window.card_display_dates.comparison_date = "2017-09-05";
    //        var start = moment.utc("2017-06-01");
    //        var end = moment.utc("2017-06-12");
    //        var weeks = VisualScheduleCard._get_weeks_from_range([start, end]);
    //
    //        var default_period = VisualScheduleCard._get_default_period(weeks, null);
    //        assert.equal(default_period, "22")
    //    });
    //});
});


{'fraction_non_alphanumeric': 0.145709591810944, 'fraction_numerical': 0.015417667130039177, 'mean_word_length': 1.9042201834862384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2639844', 'n_tokens_mistral': 2322, 'n_tokens_neox': 2166, 'n_words': 323}