-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
167 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,6 @@ spm_modules | |
.happypack | ||
dist | ||
build | ||
coverage | ||
package-lock.json | ||
assets/**/*.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,56 @@ | ||
{ | ||
"name": "uxcore-popover", | ||
"version": "0.5.2", | ||
"description": "uxcore-popover component for uxcore.", | ||
"repository": "https://github.com/uxcore/uxcore-popover.git", | ||
"author": "eternalsky", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"start": "uxcore-tools run start", | ||
"server": "uxcore-tools run server", | ||
"lint": "uxcore-tools run lint", | ||
"build": "uxcore-tools run build", | ||
"test": "uxcore-tools run test", | ||
"coverage": "uxcore-tools run coverage", | ||
"pub": "uxcore-tools run pub", | ||
"dep": "uxcore-tools run dep", | ||
"tnpm-dep": "uxcore-tools run tnpm-dep", | ||
"chrome": "uxcore-tools run chrome", | ||
"browsers": "uxcore-tools run browsers", | ||
"saucelabs": "uxcore-tools run saucelabs", | ||
"update": "uxcore-tools run update" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/uxcore/uxcore-popover/issues" | ||
}, | ||
"keywords": [ | ||
"react", | ||
"react-component", | ||
"uxcore-popover", | ||
"Popover", | ||
"" | ||
], | ||
"devDependencies": { | ||
"console-polyfill": "^0.2.2", | ||
"es5-shim": "^4.5.8", | ||
"expect.js": "~0.3.1", | ||
"kuma-base": "1.x", | ||
"react": "0.14.x", | ||
"react-addons-test-utils": "0.14.x", | ||
"react-dom": "0.14.x", | ||
"uxcore-kuma": "2.x", | ||
"uxcore-tools": "0.2.x" | ||
}, | ||
"dependencies": { | ||
"classnames": "^2.1.2", | ||
"object-assign": "^4.0.0", | ||
"rc-tooltip": "~3.3.0", | ||
"uxcore-button": "~0.3.0" | ||
}, | ||
"contributors": [], | ||
"license": "MIT" | ||
"name": "uxcore-popover", | ||
"version": "0.5.3", | ||
"description": "uxcore-popover component for uxcore.", | ||
"repository": "https://github.com/uxcore/uxcore-popover.git", | ||
"author": "eternalsky", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"start": "uxcore-tools run start", | ||
"server": "uxcore-tools run server", | ||
"lint": "uxcore-tools run lint", | ||
"build": "uxcore-tools run build", | ||
"test": "uxcore-tools run test", | ||
"coverage": "uxcore-tools run coverage", | ||
"pub": "uxcore-tools run pub", | ||
"dep": "uxcore-tools run dep", | ||
"tnpm-dep": "uxcore-tools run tnpm-dep", | ||
"chrome": "uxcore-tools run chrome", | ||
"browsers": "uxcore-tools run browsers", | ||
"saucelabs": "uxcore-tools run saucelabs", | ||
"update": "uxcore-tools run update", | ||
"tnpm-update": "uxcore-tools run tnpm-update" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/uxcore/uxcore-popover/issues" | ||
}, | ||
"keywords": [ | ||
"react", | ||
"react-component", | ||
"uxcore-popover", | ||
"Popover", | ||
"" | ||
], | ||
"devDependencies": { | ||
"console-polyfill": "^0.2.2", | ||
"enzyme": "^3.0.0", | ||
"enzyme-adapter-react-15": "^1.0.0", | ||
"es5-shim": "^4.5.8", | ||
"expect.js": "~0.3.1", | ||
"kuma-base": "1.x", | ||
"react": "15.x", | ||
"react-dom": "15.x", | ||
"react-test-renderer": "15.x", | ||
"uxcore-kuma": "*", | ||
"uxcore-tools": "0.2.x" | ||
}, | ||
"dependencies": { | ||
"classnames": "^2.1.2", | ||
"object-assign": "^4.0.0", | ||
"prop-types": "15.x", | ||
"rc-tooltip": "~3.3.0", | ||
"uxcore-button": "~0.3.0" | ||
}, | ||
"contributors": [], | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
* All rights reserved. | ||
*/ | ||
|
||
module.exports = require('./Popover'); | ||
module.exports = require('./Popover'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,94 @@ | ||
import expect from 'expect.js'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import TestUtils, { Simulate } from 'react-addons-test-utils'; | ||
import TestUtils, { Simulate } from 'react-dom/test-utils'; | ||
import Popover from '../src'; | ||
|
||
describe('Popover', () => { | ||
|
||
it('Could be rendered without overlay and with visiable true', function () { | ||
const component = TestUtils.renderIntoDocument( | ||
<Popover | ||
placement="right" | ||
title={'右边'} | ||
prefixCls="unit-test" | ||
showButton={true} | ||
visible={true} | ||
> | ||
<span className="overlay-inner-text">右边</span> | ||
</Popover> | ||
); | ||
expect(component.state.visible).equal(true); | ||
}); | ||
|
||
it('Could be rendered with visiable false', function () { | ||
let onCancleCalled = false; | ||
let onVisibleChangeCalled = false; | ||
let onOkCalled = false; | ||
const props = { | ||
placement: 'right', | ||
title: '右边', | ||
prefixCls: 'unit-test', | ||
showButton: true, | ||
visible: false, | ||
onCancle: () => {onCancleCalled = true}, | ||
onVisibleChange: () => {onVisibleChangeCalled = true}, | ||
onOk: (cb) => { | ||
cb(); | ||
onOkCalled = true; | ||
} | ||
}; | ||
const component = TestUtils.renderIntoDocument( | ||
<Popover | ||
{...props} | ||
> | ||
<span className="overlay-inner-text">右边</span> | ||
</Popover> | ||
); | ||
expect(component.state.visible).equal(false); | ||
component.setState({ ...component.state, visible: true }, () => { | ||
expect(component.state.visible).equal(true); | ||
component.handleOkClick(); | ||
component.handleCancelClick(); | ||
setTimeout(() => { | ||
expect(onVisibleChangeCalled).equal(true); | ||
expect(onCancleCalled).equal(true); | ||
expect(onOkCalled).equal(true); | ||
}, 200); | ||
component.componentWillReceiveProps({...props, visible: true}); | ||
}); | ||
}); | ||
|
||
it('Could be rendered with overlay without visiable', function () { | ||
let onCancleCalled = false; | ||
let onVisibleChangeCalled = false; | ||
let onOkCalled = false; | ||
const overlay = (<div> | ||
<div className="demoContent"> | ||
<span>目标删除后将不可恢复,如有子目标将会删除!</span> | ||
</div> | ||
</div>); | ||
const component = TestUtils.renderIntoDocument( | ||
<Popover placement="right" title={'右边'} overlay={overlay} | ||
onCancle = {() => {onCancleCalled = true}} | ||
onVisibleChange = {() => {onVisibleChangeCalled = true}} | ||
onOk = {(cb) => { | ||
cb(); | ||
onOkCalled = true; | ||
}}> | ||
<span>右边</span> | ||
</Popover> | ||
); | ||
expect(component.state.visible).equal(false); | ||
component.componentWillReceiveProps({visible: true}); | ||
component.handleOkClick(); | ||
component.handleCancelClick(); | ||
component.handleVisibleChange(); | ||
setTimeout(() => { | ||
expect(onVisibleChangeCalled).equal(true); | ||
expect(onCancleCalled).equal(true); | ||
expect(onOkCalled).equal(true); | ||
}, 200); | ||
}); | ||
|
||
}); |