Sha256: 5a25e783d956c7cbe43dd3e90d4c8ae4ea35d5e58b25f89b187f47257fd95e3e

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

describe("Mod.DOM", function() {
    var dom;

    beforeEach(function() {
        dom = new Mod.DOM;
    });

    it("should have a cache", function() {
        expect(dom.cache).toEqual({});
    });

    it("should have an is_ready property", function() {
        expect(is_bool(dom.is_ready)).toBeTruthy();
    });

    it("should add an element to the cache", function() {
        dom.addElement('foo', document.getElementById('body'));
        expect(dom.cache.foo).toEqual(document.getElementById('body'));
    });

    it("should add a hash of elements to the cache", function() {
        dom.addElements({
            bar: document.getElementsByTagName('html')[0],
            baz: document.getElementsByTagName('head')[0]
        });

        expect(dom.cache.bar).toEqual(document.getElementsByTagName('html')[0]);
        expect(dom.cache.baz).toEqual(document.getElementsByTagName('head')[0]);
    });

    it("should have an addEvent method", function() {
        expect(dom.addEvent).toBeTruthy();
    });

    it("should have a removeEvent method", function() {
        expect(dom.removeEvent).toBeTruthy();
    });

    it("should have a callWhenReady method", function() {
        dom.callWhenReady(function() {
            var body = document.getElementsByTagName('body')[0],
                h1 = document.createElement('h1');

                h1.setAttribute('id', 'foo');
                body.appendChild(h1);
                expect(document.getElementById('foo')).toBeTruthy();
        });
    });
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
modjs-architecture-0.6.7 spec/javascripts/dom_spec.js
modjs-architecture-0.6.6 spec/javascripts/dom_spec.js
modjs-architecture-0.6.4 spec/javascripts/dom_spec.js
modjs-architecture-0.6.3 spec/javascripts/dom_spec.js
modjs-architecture-0.6.2 spec/javascripts/dom_spec.js
modjs-architecture-0.6.1 spec/javascripts/dom_spec.js
modjs-architecture-0.6.0 spec/javascripts/dom_spec.js