import { expect } from 'chai';

class {
    onCreate(input, out) {
        // if (typeof window !== 'undefined') {
        //     throw new Error('onCreate should not be called in the browser');
        // }
        if (this.state != null) {
            throw new Error('this.state should be undefined');
        }
        this.state = {
            events: ['onCreate']
        }

        this.onCreateInputName = input.name;
        this.onCreateOutName = out.global.name;
    }

    onRender(out) {
        // if (typeof window !== 'undefined') {
        //     throw new Error('onRender should not be called in the browser');
        // }

        this.state.events.push('onRender');

        if (!out || !out.write) {
            throw new Error('"out" argument expected');
        }
    }

    onInput(input) {
        // if (typeof window !== 'undefined') {
        //     throw new Error('onInput should not be called in the browser');
        // }

        this.state.events.push('onInput[' + input.name + ']');
    }

    onMount() {
        var componentsLookup = window.components || (window.components = {});
        componentsLookup['lifecycle-events'] = this;
    }

    test() {
        expect(this.state.events).to.deep.equal(['onCreate', 'onInput[Frank]', 'onRender']);
        expect(this.onCreateInputName).to.equal('Frank');
        expect(this.onCreateOutName).to.equal('FrankGlobal');
    }
}

<div>
    Hello <span.name>${input.name}</span>!
</div>
