mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
feat(packages/vue): add useContextFactory composable
This commit is contained in:
@@ -37,7 +37,7 @@ function testFactory<Data>(
|
||||
// TODO: maybe replace template with passing mock functions to setup
|
||||
|
||||
describe('useContextFactory', () => {
|
||||
it('should provide and inject context correctly', () => {
|
||||
it('provide and inject context correctly', () => {
|
||||
const { Parent } = testFactory('test');
|
||||
|
||||
const component = mount(Parent);
|
||||
@@ -45,13 +45,13 @@ describe('useContextFactory', () => {
|
||||
expect(component.text()).toBe('test');
|
||||
});
|
||||
|
||||
it('should throw an error when context is not provided', () => {
|
||||
it('throw an error when context is not provided', () => {
|
||||
const { Child } = testFactory('test');
|
||||
|
||||
expect(() => mount(Child)).toThrow(VueToolsError);
|
||||
});
|
||||
|
||||
it('should inject a fallback value when context is not provided', () => {
|
||||
it('inject a fallback value when context is not provided', () => {
|
||||
const { Child } = testFactory('test', { fallback: 'fallback' });
|
||||
|
||||
const component = mount(Child);
|
||||
@@ -59,7 +59,7 @@ describe('useContextFactory', () => {
|
||||
expect(component.text()).toBe('fallback');
|
||||
});
|
||||
|
||||
it('should correctly handle null values', () => {
|
||||
it('correctly handle null values', () => {
|
||||
const { Parent } = testFactory(null);
|
||||
|
||||
const component = mount(Parent);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { inject, provide, type InjectionKey } from 'vue';
|
||||
import { VueToolsError } from '../../utils';
|
||||
import { VueToolsError } from '../..';
|
||||
|
||||
/**
|
||||
* @name useContextFactory
|
||||
|
||||
Reference in New Issue
Block a user