Skip to content

Commit

Permalink
Bump Plug JS to 0.12.1 (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed Feb 6, 2023
1 parent 7f7b08d commit da86162
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
"@croct/plug": "^0.12.0",
"@croct/plug": "^0.12.1",
"@croct/sdk": "^0.12.3"
},
"devDependencies": {
Expand Down
14 changes: 8 additions & 6 deletions src/components/Slot/index.d.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ describe('<Slot /> typing', () => {
`;

const slotMapping = `
type HomeBannerProps = {
type HomeBanner = {
title: string,
subtitle: string,
};
declare module '@croct/plug/slot' {
type HomeBannerV1 = HomeBanner & {_component: 'banner@v1' | null};
interface SlotMap {
'home-banner': HomeBannerProps;
'home-banner': HomeBannerV1;
}
}
`;
Expand Down Expand Up @@ -199,7 +201,7 @@ describe('<Slot /> typing', () => {

expect(() => compileCode(code)).not.toThrow();

expect(getParameterType(code)).toBe('HomeBannerProps & {_component: string | null;}');
expect(getParameterType(code)).toBe('HomeBannerV1');
});

it('should allow a covariant renderer parameter type for mapped slots', () => {
Expand Down Expand Up @@ -240,7 +242,7 @@ describe('<Slot /> typing', () => {

expect(() => compileCode(code)).not.toThrow();

expect(getParameterType(code)).toBe('boolean | (HomeBannerProps & {_component: string | null;})');
expect(getParameterType(code)).toBe('boolean | HomeBannerV1');
});

it('should allow a renderer that accepts the initial value for mapped slots', () => {
Expand Down Expand Up @@ -281,7 +283,7 @@ describe('<Slot /> typing', () => {

expect(() => compileCode(code)).not.toThrow();

expect(getParameterType(code)).toBe('boolean | (HomeBannerProps & {_component: string | null;})');
expect(getParameterType(code)).toBe('boolean | HomeBannerV1');
});

it('should allow a renderer that accepts the fallback value for mapped slots', () => {
Expand Down Expand Up @@ -322,7 +324,7 @@ describe('<Slot /> typing', () => {

expect(() => compileCode(code)).not.toThrow();

expect(getParameterType(code)).toBe('number | boolean | (HomeBannerProps & {_component: string | null;})');
expect(getParameterType(code)).toBe('number | boolean | HomeBannerV1');
});

it('should allow a renderer that accepts both the initial and fallback values for mapped slots', () => {
Expand Down
16 changes: 9 additions & 7 deletions src/hooks/useContent.d.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ describe('useContent typing', () => {
};
declare module '@croct/plug/slot' {
type HomeBannerV1 = HomeBanner & {_component: 'banner@v1' | null};
interface VersionedSlotMap {
'home-banner': {
'latest': HomeBanner,
'1': HomeBanner,
'latest': HomeBannerV1,
'1': HomeBannerV1,
};
}
}
Expand Down Expand Up @@ -137,7 +139,7 @@ describe('useContent typing', () => {
);

expect(getReturnType(code)).toBe(
'(Banner & {_component: "banner@1";}) | (Carousel & {_component: "carousel@1";})',
'(Banner & {_component: "banner@1" | null;}) | (Carousel & {...;})',
);
});

Expand Down Expand Up @@ -283,7 +285,7 @@ describe('useContent typing', () => {

expect(getTypeName(code)).toBe('useContent<"home-banner">');

expect(getReturnType(code)).toBe('HomeBanner & {_component: string | null;}');
expect(getReturnType(code)).toBe('HomeBannerV1');
});

it('should include the type of the initial value on the return type for mapped slots', () => {
Expand All @@ -298,7 +300,7 @@ describe('useContent typing', () => {

expect(getTypeName(code)).toBe('useContent<boolean, "home-banner">');

expect(getReturnType(code)).toBe('boolean | (HomeBanner & {_component: string | null;})');
expect(getReturnType(code)).toBe('boolean | HomeBannerV1');
});

it('should include the type of the fallback value on the return type for mapped slots', () => {
Expand All @@ -313,7 +315,7 @@ describe('useContent typing', () => {

expect(getTypeName(code)).toBe('useContent<number, "home-banner">');

expect(getReturnType(code)).toBe('number | (HomeBanner & {_component: string | null;})');
expect(getReturnType(code)).toBe('number | HomeBannerV1');
});

it('should include the types of both the initial and fallback values on the return type for mapped slots', () => {
Expand All @@ -328,7 +330,7 @@ describe('useContent typing', () => {

expect(getTypeName(code)).toBe('useContent<boolean, number, "home-banner">');

expect(getReturnType(code)).toBe('number | boolean | (HomeBanner & {...;})');
expect(getReturnType(code)).toBe('number | boolean | HomeBannerV1');
});

it('should not allow overriding the return type for mapped slots', () => {
Expand Down

0 comments on commit da86162

Please sign in to comment.