Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "refactor: refactor stub-components.js (#544)" This reverts commit db5e07e. * Revert "refactor: refactor add-slots.js (#556)" This reverts commit ce9e1bf. * delete packages/test-utils/src/shallow.js * add functions * add type SlotValue * add test * fix slotValue * fix validateEnvironment * add test * fix lint * Update slots.spec.js
- Loading branch information
1 parent
1a4d12f
commit d8485f5
Showing
10 changed files
with
227 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
// @flow | ||
|
||
import { throwError, toArray, isObject } from 'shared/util' | ||
import { compileToFunctions } from 'vue-template-compiler' | ||
import { throwError } from 'shared/util' | ||
|
||
function isValidSlot (slot: any): boolean { | ||
return Array.isArray(slot) || (slot !== null && typeof slot === 'object') || typeof slot === 'string' | ||
} | ||
|
||
export function validateSlots (slots: Object): void { | ||
Object.keys(slots).forEach(key => { | ||
toArray(slots[key]).forEach(slotValue => { | ||
if (!isObject(slotValue) && typeof slotValue !== 'string') { | ||
throwError('slots[key] must be a Component, string or an array of Components') | ||
} | ||
slots && Object.keys(slots).forEach((key) => { | ||
if (!isValidSlot(slots[key])) { | ||
throwError('slots[key] must be a Component, string or an array of Components') | ||
} | ||
|
||
if (typeof slotValue === 'string') { | ||
if (!compileToFunctions) { | ||
throwError('vueTemplateCompiler is undefined, you must pass components explicitly if vue-template-compiler is undefined') | ||
} | ||
if (typeof window === 'undefined') { | ||
throwError('the slots string option does not support strings in server-test-uitls.') | ||
} | ||
if (window.navigator.userAgent.match(/PhantomJS/i)) { | ||
throwError('the slots option does not support strings in PhantomJS. Please use Puppeteer, or pass a component.') | ||
if (Array.isArray(slots[key])) { | ||
slots[key].forEach((slotValue) => { | ||
if (!isValidSlot(slotValue)) { | ||
throwError('slots[key] must be a Component, string or an array of Components') | ||
} | ||
} | ||
}) | ||
}) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.