Skip to content

Commit

Permalink
correct test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
skmanoj322 committed Mar 25, 2024
1 parent 168604e commit 71992c1
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ describe('@mui/codemod', () => {
describe('deprecations', () => {
describe('badge-props', () => {
it('transforms props as needed', () => {
const actual = transform(
{ source: read('./test-cases/actual.js') },
{ jscodeshift },
{ printOptions: { trailingComma: true } },
);
const actual = transform({ source: read('./test-cases/actual.js') }, { jscodeshift }, {});

const expected = read('./test-cases/expected.js');
expect(actual).to.equal(expected, 'The transformed version should be correct');
});

it('should be idempotent', () => {
const actual = transform({ source: read('./test-cases/actual.js') }, { jscodeshift }, {});
const actual = transform({ source: read('./test-cases/expected.js') }, { jscodeshift }, {});

const excepted = read('./test-cases/expected.js');
expect(actual).to.equal(excepted, 'The transformed version should be correct');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,32 @@
import { Badge } from '@mui/material';

<Badge
slots={{
root: ComponentsRoot,
}}
slotProps={{ root: componentsRootProps }}
/>;
<Badge slots={{
root: ComponentsRoot
}} slotProps={{ root: componentsRootProps }} />;

<Badge
slots={{
badge: SlotsBadge,
root: ComponentsRoot,
root: ComponentsRoot
}}
slotProps={{
badge: slotsBadgeProps,
root: componentsRootProps,
}}
/>;
root: componentsRootProps
}} />;

<Badge
slots={{ root: SlotsRoot, badge: SlotsBadge }}
slotProps={{
badge: slotsBadgeProps,
root: {
...componentsRootProps,
...slotsRootProps,
},
}}
/>;
slotProps={{ badge: slotsBadgeProps, root: {
...componentsRootProps,
...slotsRootProps
} }} />;

<Badge
slots={{ root: SlotsRoot, badge: SlotsBadge }}
slotProps={{
root: {
...componentsRootProps,
...slotsRootProps,
},
badge: {
...componentsBadgeProps,
...slotsBadgeProps,
},
}}
/>;
slotProps={{ root: {
...componentsRootProps,
...slotsRootProps
}, badge: {
...componentsBadgeProps,
...slotsBadgeProps
} }} />;
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ fn({
},
},
});

fn({
MuiBadge: {
defaultProps: {
components: { root: ComponentsRoot },
slots: { badge: SlotsBadge, root: SlotsRoot },
componentsProps: { root: componentsRootProps, badge: componentsBadgeProps },
slotProps: { badge: slotsBadgeProps, root: slotsRootProps },
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ fn({
MuiBadge: {
defaultProps: {
slots: {
root: ComponentsRoot,
root: ComponentsRoot
},

slotProps: {
root: componentsRootProps,
},
root: componentsRootProps
}
},
},
});
Expand All @@ -17,13 +17,13 @@ fn({
defaultProps: {
slots: {
root: ComponentsRoot,
badge: SlotsBadge,
badge: SlotsBadge
},

slotProps: {
root: componentsRootProps,
badge: slotsBadgeProps,
},
badge: slotsBadgeProps
}
},
},
});
Expand All @@ -33,17 +33,40 @@ fn({
defaultProps: {
slots: {
root: SlotsRoot,
badge: SlotsBadge,
badge: SlotsBadge
},

slotProps: {
root: {
...componentsRootProps,
...slotsRootProps,
...slotsRootProps
},

badge: slotsBadgeProps,
badge: slotsBadgeProps
}
},
},
});

fn({
MuiBadge: {
defaultProps: {
slots: {
root: SlotsRoot,
badge: SlotsBadge
},

slotProps: {
root: {
...componentsRootProps,
...slotsRootProps
},

badge: {
...componentsBadgeProps,
...slotsBadgeProps
}
}
},
},
});
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
fn({
MuiSlider: {
MuiBadge: {
defaultProps: {
slots: {
track: ComponentsTrack
root: ComponentsRoot
},

slotProps: {
track: componentsTrackProps
root: componentsRootProps
}
},
},
});

fn({
MuiSlider: {
MuiBadge: {
defaultProps: {
slots: {
track: ComponentsTrack,
rail: SlotsRail
root: ComponentsRoot,
badge: SlotsBadge
},

slotProps: {
track: componentsTrackProps,
rail: slotsRailProps
root: componentsRootProps,
badge: slotsBadgeProps
}
},
},
});

fn({
MuiSlider: {
MuiBadge: {
defaultProps: {
slots: {
track: SlotsTrack,
rail: SlotsRail
root: SlotsRoot,
badge: SlotsBadge
},

slotProps: {
track: {
...componentsTrackProps,
...slotsTrackProps
root: {
...componentsRootProps,
...slotsRootProps
},

rail: slotsRailProps
badge: slotsBadgeProps
}
},
},
});

fn({
MuiSlider: {
MuiBadge: {
defaultProps: {
slots: {
track: SlotsTrack,
rail: SlotsRail
root: SlotsRoot,
badge: SlotsBadge
},

slotProps: {
track: {
...componentsTrackProps,
...slotsTrackProps
root: {
...componentsRootProps,
...slotsRootProps
},

rail: {
...componentsRailProps,
...slotsRailProps
badge: {
...componentsBadgeProps,
...slotsBadgeProps
}
}
},
Expand Down

0 comments on commit 71992c1

Please sign in to comment.