• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / admin / 11652818544

03 Nov 2024 04:08PM UTC coverage: 20.546%. Remained the same
11652818544

push

github

twinh
test: 更新 `Select` 组件变化导致 snapshot 的变化

19 of 78 branches covered (24.36%)

143 of 696 relevant lines covered (20.55%)

2.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/components/Select.jsx
1
import { useQuery } from '@mxjs/query';
2
import { Select as OriSelect } from '@mxjs/a-form';
3
import propTypes from 'prop-types';
4
import { url as Url } from '@mxjs/app';
5

6
const Select = ({ url, afterLoad, optionsKeys = [['data', 'items'], 'data'], ...props }) => {
8✔
7
  const { data } = useQuery(Url.appendLimit(url), {
8✔
8
    onSuccess: (ret) => {
9
      for (const key of optionsKeys) {
4✔
10
        if (Array.isArray(key) && ret?.[key[0]]?.[key[1]]) {
8!
11
          ret.data = ret[key[0]][key[1]];
×
12
          break;
×
13
        }
14

15
        if (ret[key]) {
8✔
16
          ret.data = ret[key];
4✔
17
        }
18
      }
19

20
      afterLoad && afterLoad(ret);
4!
21
    },
22
  });
23

24
  return (<OriSelect options={data} {...props}/>);
8✔
25
};
26

27
Select.propTypes = {
8✔
28
  url: propTypes.string,
29
  afterLoad: propTypes.func,
30
  optionsKeys: propTypes.array,
31
};
32

33
export default Select;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc