| Conditions | 5 |
| Total Lines | 75 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import { shallowMount, createLocalVue } from '@vue/test-utils'; |
||
| 12 | |||
| 13 | async function createWrapper(privileges = [], orderSumToday = null) { |
||
| 14 | const localVue = createLocalVue(); |
||
| 15 | localVue.filter('asset', v => v); |
||
| 16 | localVue.filter('date', v => v); |
||
| 17 | localVue.filter('currency', currency); |
||
| 18 | |||
| 19 | const responseMock = { |
||
| 20 | aggregations: { |
||
| 21 | order_count_bucket: { |
||
| 22 | buckets: [] |
||
| 23 | }, |
||
| 24 | order_sum_bucket: { |
||
| 25 | buckets: [] |
||
| 26 | } |
||
| 27 | } |
||
| 28 | }; |
||
| 29 | |||
| 30 | const options = { |
||
| 31 | localVue, |
||
| 32 | stubs: { |
||
| 33 | 'sw-card': await Shopware.Component.build('sw-card'), |
||
| 34 | 'sw-chart-card': await Shopware.Component.build('sw-chart-card'), |
||
| 35 | 'sw-entity-listing': true, |
||
| 36 | 'sw-chart': true, |
||
| 37 | 'sw-select-field': await Shopware.Component.build('sw-select-field'), |
||
| 38 | 'sw-block-field': await Shopware.Component.build('sw-block-field'), |
||
| 39 | 'sw-base-field': await Shopware.Component.build('sw-base-field'), |
||
| 40 | 'sw-skeleton': true, |
||
| 41 | 'sw-help-text': true, |
||
| 42 | 'sw-ignore-class': true, |
||
| 43 | 'sw-extension-component-section': true, |
||
| 44 | 'sw-icon': true, |
||
| 45 | 'sw-field-error': true, |
||
| 46 | }, |
||
| 47 | mocks: { |
||
| 48 | $tc: (...args) => JSON.stringify([...args]), |
||
| 49 | $i18n: { |
||
| 50 | locale: 'en-GB', |
||
| 51 | messages: { |
||
| 52 | 'en-GB': dictionary |
||
| 53 | } |
||
| 54 | } |
||
| 55 | }, |
||
| 56 | provide: { |
||
| 57 | repositoryFactory: { |
||
| 58 | create: () => ({ |
||
| 59 | search: () => Promise.resolve(responseMock) |
||
| 60 | }) |
||
| 61 | }, |
||
| 62 | stateStyleDataProviderService: {}, |
||
| 63 | acl: { |
||
| 64 | can: (identifier) => { |
||
| 65 | if (!identifier) { return true; } |
||
| 66 | |||
| 67 | return privileges.includes(identifier); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | }, |
||
| 71 | computed: { |
||
| 72 | systemCurrencyISOCode() { |
||
| 73 | return 'EUR'; |
||
| 74 | }, |
||
| 75 | isSessionLoaded() { |
||
| 76 | return true; |
||
| 77 | } |
||
| 78 | } |
||
| 79 | }; |
||
| 80 | |||
| 81 | if (orderSumToday !== null) { |
||
| 82 | options.computed.hasOrderToday = () => true; |
||
| 83 | options.computed.orderSumToday = () => orderSumToday; |
||
| 84 | } |
||
| 85 | |||
| 86 | return shallowMount(await Shopware.Component.build('sw-dashboard-statistics'), options); |
||
| 87 | } |
||
| 186 |