Skip to content

Commit 498654b

Browse files
committed
fix: #26 mocha test error
1 parent 14a5cb0 commit 498654b

File tree

5 files changed

+661
-317
lines changed

5 files changed

+661
-317
lines changed

mocha-compiler.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ function noop() {
22
return null;
33
}
44

5+
require.extensions['.css'] = noop;
56
require.extensions['.less'] = noop;
67
require.extensions['.png'] = noop;
78
// ..etc

src/components/Header/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './index.less'
44
import { Link } from 'react-router'
55

66
const contextTypes = {
7-
router: PropTypes.object.isRequired
7+
router: PropTypes.object
88
};
99

1010
const { Header } = Layout;
@@ -56,7 +56,7 @@ export default class commonHeader extends React.Component {
5656
<Col span={3}>
5757
<Dropdown overlay={menu}>
5858
<a className="ant-dropdown-link" href="#">
59-
<Icon type="user" /> {username} <Icon type="down" />
59+
<Icon type="user" /> <span>{username}</span> <Icon type="down" />
6060
</a>
6161
</Dropdown>
6262
</Col>

src/views/Login/index.less

+5
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@
1919
width: 100%;
2020
}
2121
}
22+
.ant-input-affix-wrapper {
23+
.ant-input {
24+
min-height: auto;
25+
}
26+
}
2227
}

tests/Header-test.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import React from 'react';
22
import { expect } from 'chai';
33
import { shallow, mount, render } from 'enzyme';
4-
import Header from '../src/components/Header/Header';
4+
import Header from '../src/components/Header/index.jsx';
5+
6+
let auth = {
7+
user: {
8+
name: "fireyy"
9+
}
10+
};
11+
let logout = () => {};
512

613
describe("<Header />", function() {
7-
it("shallow", function() {
8-
expect(shallow(<Header />).is('.ant-layout-header')).to.equal(true);
14+
it("mount", function() {
15+
expect(mount(<Header profile={auth} logout={logout} />).find('.ant-layout-header').length).to.equal(1);
916
});
1017

11-
it("mount", function() {
12-
expect(mount(<Header />).find('.ant-layout-header').length).to.equal(1);
18+
it("pass user profile", function() {
19+
expect(mount(<Header profile={auth} logout={logout} />).find('.ant-dropdown-link span').html()).to.contain('fireyy');
1320
});
1421
});

0 commit comments

Comments
 (0)