-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bugs, add more test for uploader, increase coverage
- Loading branch information
Showing
20 changed files
with
508 additions
and
61 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
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
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Created by n7best | ||
*/ | ||
|
||
"use strict"; | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import assert from 'assert'; | ||
import WeUI from '../src/index'; | ||
|
||
const {MediaBox} = WeUI; | ||
|
||
describe('<MediaBox></MediaBox>', () => { | ||
[true, false].map(isHyperLink => { | ||
['appmsg', 'text', 'small_appmsg'].map((type)=> { | ||
[undefined, null, '', 'custom_class'].map((clazz)=>{ | ||
describe(`<MediaBox type="${type}" href="${isHyperLink}" className="${clazz}"></MediaBox>`, ()=> { | ||
const label = 'ok'; | ||
const href = 'https://weixin.qq.com'; | ||
let wrapper; | ||
if (isHyperLink) { | ||
wrapper = shallow( | ||
<MediaBox type={type} href={href} className={clazz}>{label}</MediaBox> | ||
); | ||
} | ||
else { | ||
wrapper = shallow( | ||
<MediaBox type={type} className={clazz}>{label}</MediaBox> | ||
); | ||
} | ||
|
||
it('should render <MediaBox></MediaBox> component', () => { | ||
assert(wrapper.instance() instanceof MediaBox); | ||
}); | ||
|
||
it('should render be a MediaBox without `href` attribute', ()=> { | ||
if (!isHyperLink) { | ||
assert(wrapper.type() === 'div'); | ||
} | ||
}); | ||
|
||
it('should render be a `a` with `href` attribute', ()=> { | ||
if (isHyperLink) { | ||
assert(wrapper.type() === 'a'); | ||
assert(wrapper.prop('href') === href); | ||
} | ||
}); | ||
|
||
it(`should have class with "weui_media_box" & weui_media_${type}`, ()=> { | ||
assert(wrapper.hasClass('weui_media_box')); | ||
assert(wrapper.hasClass(`weui_media_${type}`)); | ||
}); | ||
|
||
it(`should have custom class name ${clazz}`, ()=>{ | ||
if (clazz) { | ||
assert(wrapper.hasClass(`${clazz}`)); | ||
} | ||
}); | ||
|
||
it(`should have text ${label}`, ()=> { | ||
assert(wrapper.text() === label); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Created by n7best | ||
*/ | ||
|
||
"use strict"; | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import assert from 'assert'; | ||
import WeUI from '../src/index'; | ||
|
||
const {MediaBoxBody} = WeUI; | ||
|
||
describe('<MediaBoxBody></MediaBoxBody>', ()=> { | ||
[undefined, null, '', 'custom_class'].map((clazz)=>{ | ||
['MediaBox body wording', <img src="http://mmrb.github.io/avatar/jf.jpg" />, <div><h2 className="title">文章标题</h2><p className="desc">文章描述</p></div>].map((child)=>{ | ||
describe(`<MediaBoxBody className=${clazz}>${child}</MediaBoxBody>`, ()=>{ | ||
const wrapper = shallow( | ||
<MediaBoxBody className={clazz}>{child}</MediaBoxBody> | ||
); | ||
|
||
it(`should render <MediaBoxBody></MediaBoxBody> component `, ()=>{ | ||
assert(wrapper.instance() instanceof MediaBoxBody); | ||
}); | ||
|
||
it(`should have 'weui_media_bd' class name`, ()=>{ | ||
assert(wrapper.hasClass(`weui_media_bd`)); | ||
}); | ||
|
||
it(`should have custom class name ${clazz}`, ()=>{ | ||
if (clazz) { | ||
assert(wrapper.hasClass(`${clazz}`)); | ||
} | ||
}); | ||
|
||
it(`should have child ${child}`, ()=>{ | ||
assert(wrapper.contains(child)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.