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