Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Dec 1, 2015
1 parent a977d7f commit 2c06ae7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
22 changes: 11 additions & 11 deletions examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import 'rc-notification/assets/index.css';
import Notification from 'rc-notification';
import React from 'react';
import ReactDOM from 'react-dom';
var notification = Notification.newInstance({});
const notification = Notification.newInstance({});

function simpleFn() {
notification.notice({
key: 'simple',
content: <span>simple show</span>,
onClose() {
console.log('simple close');
}
})
},
});
}

function durationFn() {
notification.notice({
content: <span>can not close...</span>,
duration: null
})
duration: null,
});
}

function closableFn() {
Expand All @@ -29,24 +29,24 @@ function closableFn() {
onClose() {
console.log('closable close');
},
closable: true
})
closable: true,
});
}

function close(key) {
notification.removeNotice(key);
}

function manualClose() {
var key = 'manual';
const key = 'manual';
notification.notice({
content: <div>
<p>click below button to close</p>
<button onClick={close.bind(null,key)}>close</button>
<button onClick={close.bind(null, key)}>close</button>
</div>,
key: key,
duration: null
})
duration: null,
});
}

ReactDOM.render(<div>
Expand Down
2 changes: 1 addition & 1 deletion src/Notification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Notification = React.createClass({
},
});

Notification.newInstance = function(properties) {
Notification.newInstance = function newNotificationInstance(properties) {
const props = properties || {};
const div = document.createElement('div');
document.body.appendChild(div);
Expand Down
25 changes: 12 additions & 13 deletions tests/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
var Notification = require('../');
var React = require('react');
var TestUtils = require('react-addons-test-utils');
var Simulate = TestUtils.Simulate;
var expect = require('expect.js');
const Notification = require('../');
const React = require('react');
const TestUtils = require('react-addons-test-utils');
const expect = require('expect.js');
require('../assets/index.css');

describe('rc-notification', function () {
it('works', function (done) {
var notification = Notification.newInstance();
describe('rc-notification', function() {
it('works', function(done) {
const notification = Notification.newInstance();
notification.notice({
content: <p className="test">1</p>,
duration: 0.1
duration: 0.1,
});
expect(TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length).to.be(1);
setTimeout(function () {
setTimeout(function() {
expect(TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length).to.be(0);
notification.destroy();
done();
}, 1000);
});

it('destroy works', function () {
var notification = Notification.newInstance();
it('destroy works', function() {
const notification = Notification.newInstance();
notification.notice({
content: <p id="test" className="test">222222</p>,
duration: 0.1
duration: 0.1,
});
expect(TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length).to.be(1);
notification.destroy();
Expand Down

0 comments on commit 2c06ae7

Please sign in to comment.