Skip to content

Commit

Permalink
fixed build of virtualdom tests wrt recent changes to vdom custom ren…
Browse files Browse the repository at this point in the history
…derers

- still need to actually try running the tests
  • Loading branch information
telamonian committed Jan 26, 2020
1 parent 5711b2f commit ccd3b10
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions packages/virtualdom/tests/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'chai';

import {
VirtualDOM, VirtualElement, VirtualElementPass, VirtualText, h, hpass
VirtualDOM, VirtualElement, VirtualText, h
} from '@lumino/virtualdom';


Expand Down Expand Up @@ -109,16 +109,16 @@ describe('@lumino/virtualdom', () => {
describe('#constructor()', () => {

it('should create a virtual element node', () => {
let vnode = new VirtualElementPass('div', {}, mockRenderer);
expect(vnode).to.be.an.instanceof(VirtualElementPass);
let vnode = new VirtualElement('div', {}, [], mockRenderer);
expect(vnode).to.be.an.instanceof(VirtualElement);
});

});

describe('#type', () => {

it('should be `element`', () => {
let vnode = new VirtualElementPass('div', {}, mockRenderer);
let vnode = new VirtualElement('div', {}, [], mockRenderer);
expect(vnode.type).to.equal('passthru');
});

Expand All @@ -127,7 +127,7 @@ describe('@lumino/virtualdom', () => {
describe('#tag', () => {

it('should be the element tag name', () => {
let vnode = new VirtualElementPass('img', {}, mockRenderer);
let vnode = new VirtualElement('img', {}, [], mockRenderer);
expect(vnode.tag).to.equal('img');
});

Expand All @@ -137,7 +137,7 @@ describe('@lumino/virtualdom', () => {

it('should be the element attrs', () => {
let attrs = { className: 'baz' };
let vnode = new VirtualElementPass('img', attrs, mockRenderer);
let vnode = new VirtualElement('img', attrs, [], mockRenderer);
expect(vnode.attrs).to.deep.equal(attrs);
});

Expand All @@ -146,7 +146,7 @@ describe('@lumino/virtualdom', () => {
describe('#renderer', () => {

it('should be the element children renderer', () => {
let vnode = new VirtualElementPass('div', {}, mockRenderer);
let vnode = new VirtualElement('div', {}, [], mockRenderer);
expect(vnode.renderer!.render).to.equal(mockRenderer.render);
expect(vnode.renderer!.unrender).to.equal(mockRenderer.unrender);
});
Expand Down Expand Up @@ -353,47 +353,47 @@ describe('@lumino/virtualdom', () => {
unrender: (host: HTMLElement) =>{}
};

it('should create a new virtual element passthru node', () => {
let vnode = hpass(
it('should create a new virtual element with custom renderer', () => {
let vnode = h(
tag,
attrs,
mockRenderer
);
expect(vnode).to.be.an.instanceof(VirtualElementPass);
expect(vnode).to.be.an.instanceof(VirtualElement);
expect(vnode.tag).to.equal(tag);
expect(vnode.attrs).to.deep.equal(attrs);
expect(vnode.renderer!.render).to.equal(mockRenderer.render);
expect(vnode.renderer!.unrender).to.equal(mockRenderer.unrender);
});

it('should create a passthru vnode without attrs', () => {
let vnode = hpass(
it('should create a virtual element with custom renderer and without attrs', () => {
let vnode = h(
'div',
mockRenderer
);
expect(vnode).to.be.an.instanceof(VirtualElementPass);
expect(vnode).to.be.an.instanceof(VirtualElement);
expect(vnode.tag).to.equal('div');
expect(vnode.attrs).to.deep.equal({});
expect(vnode.renderer!.render).to.equal(mockRenderer.render);
expect(vnode.renderer!.unrender).to.equal(mockRenderer.unrender);
});

it('should create a passthru vnode without renderer', () => {
let vnode = hpass(
it('should create a virtual element without custom renderer and with attrs', () => {
let vnode = h(
'div',
attrs
);
expect(vnode).to.be.an.instanceof(VirtualElementPass);
expect(vnode).to.be.an.instanceof(VirtualElement);
expect(vnode.tag).to.equal(tag);
expect(vnode.attrs).to.deep.equal(attrs);
expect(vnode.renderer).to.equal(null);
});

it('should create a passthru vnode without attrs or renderer', () => {
let vnode = hpass(
it('should create a virtual element without custom renderer or attrs', () => {
let vnode = h(
'div'
);
expect(vnode).to.be.an.instanceof(VirtualElementPass);
expect(vnode).to.be.an.instanceof(VirtualElement);
expect(vnode.tag).to.equal('div');
expect(vnode.attrs).to.deep.equal({});
expect(vnode.renderer).to.equal(null);
Expand Down Expand Up @@ -551,7 +551,7 @@ describe('@lumino/virtualdom', () => {

describe('realize()', () => {
it('should realize successfully', () => {
let node = VirtualDOM.realize(hpass('span', rendererClosure()));
let node = VirtualDOM.realize(h('span', rendererClosure()));
expect(node.tagName.toLowerCase()).to.equal('span');
expect(node.children[0].tagName.toLowerCase()).to.equal('div');
expect(node.children[0].className).to.equal('p-render');
Expand All @@ -563,7 +563,7 @@ describe('@lumino/virtualdom', () => {
it('should render successfully at top of tree', () => {
let host = document.createElement('div');

VirtualDOM.render(hpass('span', rendererClosure()), host);
VirtualDOM.render(h('span', rendererClosure()), host);
expect(host.children[0].tagName.toLowerCase()).to.equal('span');
expect(host.children[0].children[0].tagName.toLowerCase()).to.equal('div');
expect(host.children[0].children[0].className).to.equal('p-render');
Expand All @@ -573,7 +573,7 @@ describe('@lumino/virtualdom', () => {
let host = document.createElement('div');
let record: any = {child: undefined, cleanedUp: false};

let children = [h.a(), h.span(), h.div(h.div(), hpass('span', rendererClosure(record)), h.div())];
let children = [h.a(), h.span(), h.div(h.div(), h('span', rendererClosure(record)), h.div())];
VirtualDOM.render(children, host);
expect(host.children[2].children[1].children[0]).to.equal(record.child);
expect(host.children[2].children[1].children[0].className).to.equal('p-render');
Expand All @@ -584,7 +584,7 @@ describe('@lumino/virtualdom', () => {
let record: any = {child: undefined, cleanedUp: false};

// first pass, render the hpass children
let children0 = [h.a(), h.span(), h.div(h.div(), hpass('span', rendererClosure(record)), h.div())];
let children0 = [h.a(), h.span(), h.div(h.div(), h('span', rendererClosure(record)), h.div())];
VirtualDOM.render(children0, host);

// second pass, explicitly unrender the hpass children
Expand Down

0 comments on commit ccd3b10

Please sign in to comment.