Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to update notification props by key #40

Merged
merged 2 commits into from
Apr 16, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
increase test coverage
  • Loading branch information
yevhen-hryhorevskyi committed Apr 4, 2018
commit 61b45d18d93557f695fe04b6d2db5617eb57a6db
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