Skip to content

Commit

Permalink
test(result): add test for result
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxujiang committed Aug 17, 2022
1 parent 6660e46 commit 3440acb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/result/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ spline: data
isComponent: true
---

<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-93%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-93%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-25%25-red" /></span>
## 引入

全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
Expand Down
28 changes: 28 additions & 0 deletions src/result/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import simulate from 'miniprogram-simulate';
import path from 'path';

describe('result', () => {
const result = simulate.load(path.resolve(__dirname, `../result`), {
less: true,
rootPath: path.resolve(__dirname, '../..'),
});

it(':props', () => {
const id = simulate.load({
template: `<t-result class="result" title="{{title}}" theme="{{theme}}" description="{{description}}"></t-result>`,
data: {
description: 'This is a description',
},
usingComponents: {
't-result': result,
},
});
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));
expect(comp.querySelector('.result').data.description).toBe('This is a description');
comp.setData({ theme: 'success' });
expect(comp.querySelector('.result').data.theme).toBe('success');
comp.setData({ title: 'This is title' });
expect(comp.querySelector('.result').data.title).toBe('This is title');
});
});

0 comments on commit 3440acb

Please sign in to comment.