| Conditions | 2 |
| Total Lines | 67 |
| Code Lines | 52 |
| 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'; |
||
| 108 | async function createWrapper() { |
||
| 109 | return shallowMount(await Shopware.Component.build('sw-first-run-wizard-welcome'), { |
||
| 110 | stubs: { |
||
| 111 | 'sw-container': await Shopware.Component.build('sw-container'), |
||
| 112 | 'sw-plugin-card': await Shopware.Component.build('sw-plugin-card'), |
||
| 113 | 'sw-button-process': await Shopware.Component.build('sw-button-process'), |
||
| 114 | 'sw-button': await Shopware.Component.build('sw-button'), |
||
| 115 | 'sw-modal': await Shopware.Component.build('sw-modal'), |
||
| 116 | 'sw-select-field': await Shopware.Component.build('sw-select-field'), |
||
| 117 | 'sw-block-field': await Shopware.Component.build('sw-block-field'), |
||
| 118 | 'sw-base-field': await Shopware.Component.build('sw-base-field'), |
||
| 119 | 'sw-field-error': await Shopware.Component.build('sw-field-error'), |
||
| 120 | 'sw-password-field': await Shopware.Component.build('sw-password-field'), |
||
| 121 | 'sw-text-field': await Shopware.Component.build('sw-text-field'), |
||
| 122 | 'sw-contextual-field': await Shopware.Component.build('sw-contextual-field'), |
||
| 123 | 'sw-icon': true, |
||
| 124 | 'sw-loader': true, |
||
| 125 | }, |
||
| 126 | provide: { |
||
| 127 | languagePluginService: { |
||
| 128 | getPlugins: () => Promise.resolve(languagePlugins), |
||
| 129 | }, |
||
| 130 | userService: { |
||
| 131 | getUser: () => Promise.resolve(userProfile), |
||
| 132 | }, |
||
| 133 | loginService: { |
||
| 134 | verifyUserToken: () => Promise.resolve(), |
||
| 135 | }, |
||
| 136 | extensionStoreActionService: {}, |
||
| 137 | cacheApiService: { |
||
| 138 | clear: () => Promise.resolve() |
||
| 139 | }, |
||
| 140 | extensionHelperService: { |
||
| 141 | downloadAndActivateExtension: (extension) => Promise.resolve(extension), |
||
| 142 | }, |
||
| 143 | shortcutService: { |
||
| 144 | startEventListener: () => {}, |
||
| 145 | stopEventListener: () => {} |
||
| 146 | }, |
||
| 147 | validationService: { |
||
| 148 | validate: () => true, |
||
| 149 | }, |
||
| 150 | repositoryFactory: { |
||
| 151 | create: (entity: String) => { |
||
| 152 | switch (entity) { |
||
| 153 | case 'language': |
||
| 154 | return { |
||
| 155 | search: () => Promise.resolve(searchLanguage) |
||
| 156 | }; |
||
| 157 | case 'user': |
||
| 158 | return { |
||
| 159 | search: () => Promise.resolve(searchUser), |
||
| 160 | get: () => Promise.resolve(searchUser), |
||
| 161 | save: () => Promise.resolve(), |
||
| 162 | }; |
||
| 163 | case 'snippet_set': |
||
| 164 | return { |
||
| 165 | search: () => Promise.resolve(searchSnippetSet) |
||
| 166 | }; |
||
| 167 | default: |
||
| 168 | throw new Error(`No repositoryFactory registered for entity "${entity}"`); |
||
| 169 | } |
||
| 170 | }, |
||
| 171 | }, |
||
| 172 | }, |
||
| 173 | mixins: [ |
||
| 174 | Shopware.Mixin.getByName('notification'), |
||
| 175 | ] |
||
| 201 |