| Conditions | 2 |
| Total Lines | 74 |
| Code Lines | 41 |
| 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 } from '@vue/test-utils'; |
||
| 19 | |||
| 20 | async function createWrapper(privileges = []) { |
||
| 21 | return shallowMount(await Shopware.Component.build('sw-flow-list-flow-templates'), { |
||
| 22 | mocks: { |
||
| 23 | $route: { |
||
| 24 | query: { |
||
| 25 | page: 1, |
||
| 26 | limit: 25 |
||
| 27 | } |
||
| 28 | } |
||
| 29 | }, |
||
| 30 | |||
| 31 | provide: { |
||
| 32 | repositoryFactory: { |
||
| 33 | create: () => ({ |
||
| 34 | search: () => { |
||
| 35 | return Promise.resolve(new EntityCollection('', '', Context.api, null, mockData, 1)); |
||
| 36 | } |
||
| 37 | }) |
||
| 38 | }, |
||
| 39 | |||
| 40 | acl: { |
||
| 41 | can: (identifier) => { |
||
| 42 | if (!identifier) { |
||
| 43 | return true; |
||
| 44 | } |
||
| 45 | |||
| 46 | return privileges.includes(identifier); |
||
| 47 | } |
||
| 48 | }, |
||
| 49 | |||
| 50 | searchRankingService: {} |
||
| 51 | }, |
||
| 52 | |||
| 53 | stubs: { |
||
| 54 | 'sw-page': { |
||
| 55 | template: ` |
||
| 56 | <div class="sw-page"> |
||
| 57 | <slot name="search-bar"></slot> |
||
| 58 | <slot name="smart-bar-back"></slot> |
||
| 59 | <slot name="smart-bar-header"></slot> |
||
| 60 | <slot name="language-switch"></slot> |
||
| 61 | <slot name="smart-bar-actions"></slot> |
||
| 62 | <slot name="side-content"></slot> |
||
| 63 | <slot name="content"></slot> |
||
| 64 | <slot name="sidebar"></slot> |
||
| 65 | <slot></slot> |
||
| 66 | </div> |
||
| 67 | ` |
||
| 68 | }, |
||
| 69 | 'sw-card': true, |
||
| 70 | 'sw-internal-link': await Shopware.Component.build('sw-internal-link'), |
||
| 71 | 'router-link': { |
||
| 72 | props: ['to'], |
||
| 73 | // eslint-disable-next-line no-template-curly-in-string |
||
| 74 | template: '<a :href="`${to.name}/${to.params.flowTemplateId}`">asdf</a>' |
||
| 75 | }, |
||
| 76 | 'sw-icon': true, |
||
| 77 | 'sw-button': true, |
||
| 78 | 'sw-entity-listing': { |
||
| 79 | props: ['items'], |
||
| 80 | template: ` |
||
| 81 | <div class="sw-data-grid"> |
||
| 82 | <div class="sw-data-grid__row" v-for="item in items"> |
||
| 83 | <slot name="column-name" v-bind="{ item }"></slot> |
||
| 84 | <slot name="column-createFlow" v-bind="{ item }"></slot> |
||
| 85 | <slot name="actions" v-bind="{ item }"></slot> |
||
| 86 | </div> |
||
| 87 | </div> |
||
| 88 | ` |
||
| 89 | }, |
||
| 90 | 'sw-context-menu-item': true, |
||
| 91 | 'sw-empty-state': true, |
||
| 92 | 'sw-search-bar': true |
||
| 93 | } |
||
| 158 |