Skip to content

Commit

Permalink
Add test for props.getAll()
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Medeiros committed Jun 22, 2015
1 parent 49dc115 commit bbe7dd3
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion test/browser/custom-elements.js
Expand Up @@ -109,7 +109,7 @@ describe('Custom Elements', function () {
}, 500);
});

it('should have Observable properties object as get(\'props\', \'*\')', function (done) {
it('should have Observable properties object as props.get(\'*\')', function (done) {
// Make custom element
function myElementDef(ext) {
return {
Expand Down Expand Up @@ -152,6 +152,49 @@ describe('Custom Elements', function () {
});
});

it('should have Observable properties object as props.getAll()', function (done) {
// Make custom element
function myElementDef(ext) {
return {
DOM: ext.props.getAll().map(propsObj => {
assert.strictEqual(typeof propsObj, 'object');
assert.notStrictEqual(propsObj, null);
assert.strictEqual(propsObj.color, '#FF0000');
assert.strictEqual(propsObj.content, 'Hello world');
return h('h3.inner-element',
{style: {color: propsObj.color}},
String(propsObj.content)
);
})
};
}
function app() {
return {
DOM: Rx.Observable.just(
h('div', [
h('my-element', {color: '#FF0000', content: 'Hello world'})
])
)
};
}
let [requests, responses] = Cycle.run(app, {
DOM: Cycle.makeDOMDriver(createRenderTarget(), {
'my-element': myElementDef
})
});
// Make assertions
responses.DOM.get(':root').first().subscribe(function (root) {
let myElement = root.querySelector('.inner-element');
assert.notStrictEqual(myElement, null);
assert.notStrictEqual(typeof myElement, 'undefined');
assert.strictEqual(myElement.tagName, 'H3');
assert.strictEqual(myElement.textContent, 'Hello world');
assert.strictEqual(myElement.style.color, 'rgb(255, 0, 0)');
responses.dispose();
done();
});
});

it('should throw if properties driver getter has no args', function (done) {
// Make custom element
function myElementDef(ext) {
Expand Down

0 comments on commit bbe7dd3

Please sign in to comment.