<commit_before>/*jslint browser: true, sloppy: true, todo: true, devel: true */
/*global $, it, describe, xit, xdescribe, expect, beforeEach, loadFixtures, spyOn, InteractiveModule, ScrollTrack */

//= require waypoints
//= require waypoints-sticky
//= require scroll-interactive-mod

describe('ScrollTrack', function () {
    var scrollTrack;

    beforeEach(function () {
        loadFixtures('interactive-scrolling.html');
        scrollTrack = new ScrollTrack($('.content-mod'), $('#end-scroll-track'));
    });

    it('has attributes', function () {
        expect(scrollTrack.contentModule).toBeDefined();
        expect(scrollTrack.trackEnd).toBeDefined();
        expect(scrollTrack.contentModule).toBe('div.content-mod');
        expect(scrollTrack.trackEnd).toBe('div#end-scroll-track');
    });

    describe('getTop', function () {
        it('returns the offset of the content module', function () {
            expect(scrollTrack.getTop()).toBe($('.content-mod').offset().top);
        });
    });

    describe('getBottom', function () {
        it('returns the offset of the end-scroll-track div', function () {
            expect(scrollTrack.getBottom()).toBe($('#end-scroll-track').offset().top);
        });
    });

    describe('getHeight', function () {
        it('returns the difference between its top and its bottom', function () {
            expect(scrollTrack.getHeight()).toBe($('#end-scroll-track').offset().top - $('.content-mod').offset().top);
        });
    });

    describe('isScrollable', function () {
        describe('when the track is taller than the interactive', function () {
            it('returns true', function () {
                expect(scrollTrack.isScrollable(200)).toBe(true);
            });
        });

        describe('when the track is shorter than the interactive', function () {
            it('returns false', function () {
                expect(scrollTrack.isScrollable(800)).toBe(false);
            });
        });

        describe('when the track is undefined', function () {
            it('returns false', function () {
                scrollTrack.trackEnd = $('#noSuchDiv');
                expect(scrollTrack.isScrollable(200)).toBe(false);
            });
        });
    });
});

describe('InteractiveModule', function () {
    var interactive, scrollTrack;

    beforeEach(function () {
        loadFixtures('interactive-scrolling.html');
        scrollTrack = new ScrollTrack($('.content-mod'), $('#end-scroll-track'));
        interactive = new InteractiveModule($('.pinned'), scrollTrack);
    });

    it('has attributes', function () {
        expect(interactive.bMargin).toBeDefined();
        expect(interactive.topBuffer).toBeDefined();
        expect(interactive.fudgeFactor).toBeDefined();
        expect(interactive.module).toBe('div.pinned');
    });

    describe('fixTop()', function () {
        describe('when the interactive is taller than its column', function () {
            beforeEach(function () {
                interactive.trackHeight = 300;
                interactive.iHeight = 600;
                interactive.fixTop();
            });

            it('does nothing', function () {
                expect(interactive.module).not.toHaveClass('stuck');
            });
        });

        describe('when the interactive is shorter than its column', function () {
            beforeEach(function () {
                interactive.fixTop();
            });

            it('adds the "stuck" class', function () {
                expect(interactive.module).toHaveClass('stuck');
            });

            xit('adds a CSS width', function () {
                expect(interactive.module.css('width')).toBe(interactive.iWidth + 'px');
            });
        });
    });

    describe('unFixTop()', function () {
        beforeEach(function () {
            interactive.module.addClass('stuck');
            interactive.unFixTop();
        });

        it('removes the "stuck" class', function () {
            expect(interactive.module).not.toHaveClass('stuck');
        });
    });<commit_msg>Fixing spec for scrolling interactive; green now<commit_after>/*jslint browser: true, sloppy: true, todo: true, devel: true */
/*global $, it, describe, xit, xdescribe, expect, beforeEach, loadFixtures, spyOn, InteractiveModule, ScrollTrack */

//= require waypoints
//= require waypoints-sticky
//= require scroll-interactive-mod

describe('ScrollTrack', function () {
    var scrollTrack;

    beforeEach(function () {
        loadFixtures('interactive-scrolling.html');
        scrollTrack = new ScrollTrack($('.content-mod'), $('#end-scroll-track'));
    });

    it('has attributes', function () {
        expect(scrollTrack.contentModule).toBeDefined();
        expect(scrollTrack.trackEnd).toBeDefined();
        expect(scrollTrack.contentModule).toBe('div.content-mod');
        expect(scrollTrack.trackEnd).toBe('div#end-scroll-track');
    });

    describe('getTop', function () {
        it('returns the offset of the content module', function () {
            expect(scrollTrack.getTop()).toBe($('.content-mod').offset().top);
        });
    });

    describe('getBottom', function () {
        it('returns the offset of the end-scroll-track div', function () {
            expect(scrollTrack.getBottom()).toBe($('#end-scroll-track').offset().top);
        });
    });

    describe('getHeight', function () {
        it('returns the difference between its top and its bottom', function () {
            expect(scrollTrack.getHeight()).toBe($('#end-scroll-track').offset().top - $('.content-mod').offset().top);
        });
    });

    describe('isScrollable', function () {
        describe('when the track is taller than the interactive', function () {
            it('returns true', function () {
                expect(scrollTrack.isScrollable(200)).toBe(true);
            });
        });

        describe('when the track is shorter than the interactive', function () {
            it('returns false', function () {
                expect(scrollTrack.isScrollable(800)).toBe(false);
            });
        });

        describe('when the track is undefined', function () {
            it('returns false', function () {
                scrollTrack.trackEnd = $('#noSuchDiv');
                expect(scrollTrack.isScrollable(200)).toBe(false);
            });
        });
    });
});

describe('InteractiveModule', function () {
    var interactive, scrollTrack;

    beforeEach(function () {
        loadFixtures('interactive-scrolling.html');
        scrollTrack = new ScrollTrack($('.content-mod'), $('#end-scroll-track'));
        interactive = new InteractiveModule($('.pinned'), scrollTrack);
    });

    it('has attributes', function () {
        expect(interactive.bMargin).toBeDefined();
        expect(interactive.topBuffer).toBeDefined();
        expect(interactive.fudgeFactor).toBeDefined();
        expect(interactive.module).toBe('div.pinned');
    });

    describe('fixTop()', function () {
        describe('when the interactive is taller than its column', function () {
            beforeEach(function () {
                spyOn(ScrollTrack.prototype, 'isScrollable').andReturn(false);
                // Have to re-create the test objects to incorporate the spy
                scrollTrack = new ScrollTrack($('.content-mod'), $('#end-scroll-track'));
                interactive = new InteractiveModule($('.pinned'), scrollTrack);
                interactive.module.removeClass('stuck');
            });

            it('does nothing', function () {
                interactive.fixTop();
                expect(scrollTrack.isScrollable).toHaveBeenCalled();
                expect(interactive.module).not.toHaveClass('stuck');
            });
        });

        describe('when the interactive is shorter than its column', function () {
            beforeEach(function () {
                interactive.fixTop();
            });

            it('adds the "stuck" class', function () {
                expect(interactive.module).toHaveClass('stuck');
            });

            xit('adds a CSS width', function () {
                expect(interactive.module.css('width')).toBe(interactive.iWidth + 'px');
            });
        });
    });

    describe('unFixTop()', function () {
        beforeEach(function () {
            interactive.module.addClass('stuck');
            interactive.unFixTop();
        });

        it('removes the "stuck" class', function () {
            expect(interactive.module).not.toHaveClass('stuck');
        });
    });
{'fraction_non_alphanumeric': 0.157220993832189, 'fraction_numerical': 0.002792971022925637, 'mean_word_length': 2.41031746031746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2643517', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2155, 'n_words': 418}