Skip to content

Commit

Permalink
fixed two other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Campos committed Sep 13, 2016
1 parent 9aa3b06 commit 5d0f065
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/ReactWrapper-spec.jsx
Expand Up @@ -2648,25 +2648,26 @@ describeWithDOM('mount', () => {
const Foo = () => <div className="in-foo" />;

const div = global.document.createElement('div');
const initialBodyChildren = document.body.childNodes.length;
global.document.body.appendChild(div);

expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);

const wrapper = mount(<Foo />, { attachTo: div });

expect(wrapper.find('.in-foo')).to.have.length(1);
expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);

wrapper.detach();

expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);

global.document.body.removeChild(div);

expect(document.body.childNodes).to.have.length(0);
expect(document.body.childNodes).to.have.length(initialBodyChildren);
expect(div.childNodes).to.have.length(0);
});

Expand All @@ -2676,33 +2677,34 @@ describeWithDOM('mount', () => {

let wrapper;
const div = global.document.createElement('div');
const initialBodyChildren = document.body.childNodes.length;
global.document.body.appendChild(div);

expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);

wrapper = mount(<Foo />, { attachTo: div });

expect(wrapper.find('.in-foo')).to.have.length(1);
expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);

wrapper.detach();

wrapper = mount(<Bar />, { attachTo: div });

expect(wrapper.find('.in-bar')).to.have.length(1);
expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);

wrapper.detach();

expect(document.body.childNodes).to.have.length(1);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);

global.document.body.removeChild(div);

expect(document.body.childNodes).to.have.length(0);
expect(document.body.childNodes).to.have.length(initialBodyChildren + 0);
expect(div.childNodes).to.have.length(0);
});

Expand Down

0 comments on commit 5d0f065

Please sign in to comment.