FreeAllMedia/mrt

View on GitHub
es6/spec/component/component.link.apply.spec.js

Summary

Maintainability
A
0 mins
Test Coverage
import Component from "../../lib/component/component.js";

class Person extends Component {
    initialize() {
        this.link("thought", Thought).apply(this, 0);
    }
}

class Thought extends Component {
    initialize(...options) {
        this.options = options;
    }
}

describe("component.link.apply", () => {
    let person,
            thought;

    beforeEach(() => {
        person = new Person();
        thought = person.thought(1, 2, 3);
    });

    it("should return this to enable chaining", () => {
        const link = person.link("thought", Thought);
        link.apply(this).should.eql(link);
    });

    it("should add the newly instantiated chain link to the designated collection", () => {
        thought.options.should.eql([person, 0, 1, 2, 3]);
    });
});