Skip to content

Commit

Permalink
increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhen-hryhorevskyi committed Apr 4, 2018
1 parent 6edb5ad commit 61b45d1
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,43 @@ describe('rc-notification', () => {
Notification.newInstance({}, notification => {
const key = 'updatable';
const value = 'value';
const newValue = `new-${value}`;
const notUpdatableValue = 'not-updatable-value';
notification.notice({
content: <p id="not-updatable" className="not-updatable">{notUpdatableValue}</p>,
duration: null,
});
notification.notice({
content: <p id="updatable" className="updatable">{`${value}-old`}</p>,
key,
duration: null,
});
notification.notice({
content: <p id="updatable" className="updatable">{value}</p>,
key,
duration: 0.1,
duration: null,
});

setTimeout(() => {
// Text updated successfully
expect(document.querySelectorAll('.updatable').length).to.be(1);
expect(document.querySelector('.updatable').innerText).to.be(value);

notification.notice({
content: <p id="updatable" className="updatable">{newValue}</p>,
key,
duration: 0.1,
});

setTimeout(() => {
// Other notices are not affected
expect(document.querySelectorAll('.not-updatable').length).to.be(1);
expect(document.querySelector('.not-updatable').innerText).to.be(notUpdatableValue);
// Duration updated successfully
expect(document.querySelectorAll('.updatable').length).to.be(0);
notification.destroy();
done();
}, 500);
// Text updated successfully
expect(document.querySelectorAll('.updatable').length).to.be(1);
expect(document.querySelector('.updatable').innerText).to.be(newValue);

setTimeout(() => {
// Other notices are not affected
expect(document.querySelectorAll('.not-updatable').length).to.be(1);
expect(document.querySelector('.not-updatable').innerText).to.be(notUpdatableValue);
// Duration updated successfully
expect(document.querySelectorAll('.updatable').length).to.be(0);
notification.destroy();
done();
}, 500);
}, 10);
}, 10);
});
});
Expand Down

0 comments on commit 61b45d1

Please sign in to comment.