<commit_before>var expect = chai.expect;

describe("StateManager", function() {
    var sm;
    var noop = function() {};

    beforeEach(function() {
        sm = new StateManager();
    });

    afterEach(function() {
        sm.destroy();
    });

    describe("#register", function() {
        it("should be a function", function() {
            expect(sm.register).to.exist;
        });

        it("should create a new MediaQuery object", function() {
            var query = sm.register("screen and (max-width: 768px)", noop);
            expect(sm.queries.length).to.be.gt(0);
        });
    });

    describe("#deregister", function() {
        it("should be a function", function() {
            expect(sm.register).to.exist;
        });

        it("should remove a MediaQuery object", function() {
            var query = sm.register("screen and (max-width: 768px)", noop);
            sm.deregister(query);
            expect(sm.queries.length).to.equal(0);
        });
    });

    describe("#destroy", function() {
        it("should be a function", function() {
            expect(sm.register).to.exist;
        });
    });
});
<commit_msg>extended tests<commit_after>var expect = chai.expect;

describe("StateManager", function() {
    var sm;
    var noop = function() {};

    describe("QueryHandler", function() {

        it("should have a context", function() {
            sm = new StateManager();
            expect(sm.context).to.be.not.empty;
            sm.destroy();
        });

        describe("#register", function() {

            before(function() {
                sm = new StateManager();
            });

            after(function() {
                sm.destroy();
            });

            it("should be a function", function() {
                expect(sm.register).to.exist;
            });

            it("should create a new MediaQuery object", function() {
                var query = sm.register("screen and (max-width: 768px)", noop);
                expect(sm.queries.length).not.to.be.empty;
            });
        });

        describe("#deregister", function() {

            before(function() {
                sm = new StateManager();
            });

            after(function() {
                sm.destroy();
            });

            it("should be a function", function() {
                expect(sm.register).to.exist;
            });

            it("should remove a MediaQuery object", function() {
                var query = sm.register("screen and (max-width: 768px)", noop);
                sm.deregister(query);
                expect(sm.queries.length).to.be.empty;
            });
        });

        describe("#destroy", function() {

            before(function() {
                sm = new StateManager();
            });

            after(function() {
                sm.destroy();
            });

            it("should be a function", function() {
                expect(sm.register).to.exist;
            });

            it("should remove context reference", function() {
                sm.destroy();
                expect(sm.context).to.be.undefined;
            });

            it("should remove all MediaQuery instances", function() {
                expect(sm.queries).to.be.empty;
            });
        });
    });

    describe("MediaQuery", function() {
        var query;

        before(function() {
            sm = new StateManager();
            query = sm.register("screen and (max-width: 768px)", noop);
        });

        after(function() {
            sm.destroy();
        });

        it("should inherit context", function() {
            expect(query.context).to.exist;
            expect(query.context).to.equal(sm.context);
        });

        it("should have a given handler", function() {
            expect(query.handler).to.exist;
            expect(query.handler).to.equal(noop);
        });

        it("should have a listener function", function() {
            expect(query.listenerFunction).to.exist;
            expect(query.listenerFunction).to.be.a("function");
        });

        it("should have a matchMedia instance", function() {
            expect(query.matchMedia).to.exist;
        });

        it("should have a mediquery string", function() {
            expect(query.mq).to.exist;
            expect(query.mq).to.be.a("string");
        });
    });
});

{'fraction_non_alphanumeric': 0.15163934426229508, 'fraction_numerical': 0.003870673952641166, 'mean_word_length': 1.622686567164179, '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': '4365625', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1113, 'n_words': 232}