Skip to content

Commit

Permalink
Updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 21, 2024
1 parent c8566a8 commit de50a2e
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/framework/piral-core/src/state/withApi.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ StubComponent.displayName = 'StubComponent';

describe('withApi Module', () => {
it('wraps a component and forwards the API as piral', () => {
const { context } = createMockContainer();
const api: any = {
meta: {
name: 'foo',
},
on: context.on,
off: context.off,
emit: context.emit,
};
const { context } = createMockContainer();
const Component = withApi(context, StubComponent, api, 'feed' as any);
const node = render(
<StateContext.Provider value={context}>
Expand All @@ -99,12 +102,15 @@ describe('withApi Module', () => {

it('is protected against a component crash', () => {
console.error = vitest.fn();
const { context } = createMockContainer();
const api: any = {
meta: {
name: 'foo',
},
on: context.on,
off: context.off,
emit: context.emit,
};
const { context } = createMockContainer();
const Component = withApi(context, StubComponent, api, 'feed' as any);
const node = render(
<StateContext.Provider value={context}>
Expand All @@ -116,12 +122,15 @@ describe('withApi Module', () => {

it('reports to console.error when an error is hit', () => {
console.error = vitest.fn();
const { context } = createMockContainer();
const api: any = {
meta: {
name: 'my pilet',
},
on: context.on,
off: context.off,
emit: context.emit,
};
const { context } = createMockContainer();
const Component = withApi(context, StubComponent, api, 'feed' as any);
render(
<StateContext.Provider value={context}>
Expand All @@ -132,12 +141,15 @@ describe('withApi Module', () => {
});

it('Wraps component of type object', () => {
const { context } = createMockContainer();
const api: any = {
meta: {
name: 'foo',
},
on: context.on,
off: context.off,
emit: context.emit,
};
const { context } = createMockContainer();
context.converters = {
html: ({ component }) => component,
};
Expand All @@ -153,12 +165,15 @@ describe('withApi Module', () => {
});

it('Wraps component which is object == null.', () => {
const { context } = createMockContainerWithNoWrappers();
const api: any = {
meta: {
name: 'foo',
},
on: context.on,
off: context.off,
emit: context.emit,
};
const { context } = createMockContainerWithNoWrappers();
context.converters = {
html: ({ component }) => component,
};
Expand Down

0 comments on commit de50a2e

Please sign in to comment.