Skip to content

Commit

Permalink
AKR:OTR:VKT:YKI:SHARED(Frontend) OPHAKRKEH-515 jest migration test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkkp committed Jan 4, 2024
1 parent d83ae6f commit de8d3a4
Show file tree
Hide file tree
Showing 44 changed files with 121 additions and 144 deletions.
5 changes: 4 additions & 1 deletion frontend/packages/shared/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"jsx-a11y/label-has-associated-control": [2, {
"controlComponents": ["Autocomplete", "CustomTextField"],
"depth": 3
}],
"import/order": [
"error",
{
Expand All @@ -38,7 +42,6 @@
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
],
"no-console": "warn",

"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "*", "next": "return" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
@use 'sass:map';
@use '../../styles/abstracts/mixins';
@use '../../styles/abstracts/maps';

.accessibility-statement {
& &-content {
@include mixins.phone {
gap: map-get(maps.$spacing, 'md');
gap: map.get(maps.$spacing, 'md');
}

&__caveats {
@include mixins.phone {
gap: map-get(maps.$spacing, 'md');
gap: map.get(maps.$spacing, 'md');

> div {
margin-top: map-get(maps.$spacing, 'md');
margin-top: map.get(maps.$spacing, 'md');
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export const AccessibilityStatementContent: FC<
{caveats.map(({}, i) => (
<div className="rows gapped-xs" key={i}>
<H3>{`${translateAccessibility(
`content.caveats.items.${i}.title`
`content.caveats.items.${i}.title`,
)}`}</H3>
<Text>
{translateAccessibility('content.caveats.description')}
</Text>
<Text>
{translateAccessibility(
`content.caveats.items.${i}.description`
`content.caveats.items.${i}.description`,
)}
</Text>
<div>
Expand All @@ -69,7 +69,7 @@ export const AccessibilityStatementContent: FC<
<Text>
<li>
{translateAccessibility(
`content.caveats.items.${i}.claim`
`content.caveats.items.${i}.claim`,
)}
</li>
</Text>
Expand All @@ -83,7 +83,7 @@ export const AccessibilityStatementContent: FC<
<Text>{translateAccessibility('content.feedback.subtitle')}</Text>
<Text>
{`${translateAccessibility(
'content.feedback.description'
'content.feedback.description',
)}: ${feedbackEmail}`}
</Text>
</div>
Expand All @@ -94,29 +94,29 @@ export const AccessibilityStatementContent: FC<
<div className="inline-text-box">
<Text>
{translateAccessibility(
'content.administrativeAgency.description'
'content.administrativeAgency.description',
)}
</Text>
<ExtLink
sx={agencyDescriptionLinkCss}
text={translateAccessibility(
'content.administrativeAgency.links.title'
'content.administrativeAgency.links.title',
)}
href={translateAccessibility(
'content.administrativeAgency.links.link'
'content.administrativeAgency.links.link',
)}
/>
<Text>
{translateAccessibility(
'content.administrativeAgency.extraDescription'
'content.administrativeAgency.extraDescription',
)}
</Text>
</div>
</div>
<div className="rows gapped-xxs">
<H3>
{translateAccessibility(
'content.contactAdministrativeAgency.title'
'content.contactAdministrativeAgency.title',
)}
</H3>
<Text>
Expand All @@ -129,29 +129,29 @@ export const AccessibilityStatementContent: FC<
sx={contactLinkCss}
className="accessibility-statement__content__link"
text={translateAccessibility(
`content.contactAdministrativeAgency.links.website.title`
`content.contactAdministrativeAgency.links.website.title`,
)}
href={translateAccessibility(
`content.contactAdministrativeAgency.links.website.link`
`content.contactAdministrativeAgency.links.website.link`,
)}
aria-label={translateAccessibility(
`content.contactAdministrativeAgency.links.website.ariaLabel`
`content.contactAdministrativeAgency.links.website.ariaLabel`,
)}
endIcon={<OpenInNewIcon />}
/>
<ExtLink
sx={contactLinkCss}
className="accessibility-statement__content__link"
text={translateAccessibility(
`content.contactAdministrativeAgency.links.email.title`
`content.contactAdministrativeAgency.links.email.title`,
)}
href={`mailto:${translateAccessibility(
`content.contactAdministrativeAgency.links.email.link`
`content.contactAdministrativeAgency.links.email.link`,
)}`}
/>
<Text>
{translateAccessibility(
'content.contactAdministrativeAgency.phone'
'content.contactAdministrativeAgency.phone',
)}
</Text>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('CircularStepper', () => {
phaseText="Test Phase 1"
ariaLabel="phase Test Phase 1: Description text"
value={33}
/>
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('ComboBox', () => {
variant={TextFieldVariant.Outlined}
values={values}
value={null}
/>
/>,
)
.toJSON();

Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/shared/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const sortOptionsByLabels = (options: Array<ComboBoxOption>) => {

const isOptionEqualToValue = (
option: AutocompleteValue,
value: AutocompleteValue
value: AutocompleteValue,
) => {
if (option === null && value === null) {
return true;
Expand All @@ -55,7 +55,7 @@ const isOptionEqualToValue = (

const filterOptions: (
options: Array<AutocompleteValue>,
state: FilterOptionsState<AutocompleteValue>
state: FilterOptionsState<AutocompleteValue>,
) => Array<AutocompleteValue> = createFilterOptions({
matchFrom: 'start',
trim: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
@use 'sass:map';
@use '../../styles/abstracts/maps';
@use '../../styles/abstracts/mixins';

.cookie-banner {
&__content {
margin-left: auto;
margin-right: auto;
max-width: map-get(maps.$breakpoints, 'desktop-md');
padding: 0 map-get(maps.$spacing, 'lg');
width: calc(100% - 2 * map-get(maps.$spacing, 'lg'));
max-width: map.get(maps.$breakpoints, 'desktop-md');
padding: 0 map.get(maps.$spacing, 'lg');
width: calc(100% - 2 * map.get(maps.$spacing, 'lg'));

& &__accept-button {
min-width: 96px;
}

& &__dialog-content {
height: calc(100% - map-get(maps.$spacing, 'lg'));
padding-bottom: map-get(maps.$spacing, 'lg');
height: calc(100% - map.get(maps.$spacing, 'lg'));
padding-bottom: map.get(maps.$spacing, 'lg');

@include mixins.desktop-and-up {
padding-bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('CustomButtonLink', () => {
.create(
<BrowserRouter>
<CustomButtonLink to="/" />
</BrowserRouter>
</BrowserRouter>,
)
.toJSON();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('DatePicker', () => {
label="test label"
value={dayjs('2022-04-21')}
setValue={jest.fn()}
/>
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const CustomDatePicker = ({
};

return <CustomTextField {...textFieldParams} />;
}
},
}}
/>
</LocalizationProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('CustomIconButton', () => {
.create(
<CustomIconButton>
<HelpOutlineIcon />
</CustomIconButton>
</CustomIconButton>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const CustomIconButton: FC<IconButtonProps> = forwardRef(
{props.children ?? <QuestionMark />}
</IconButton>
);
}
},
);

CustomIconButton.displayName = 'CustomIconButton';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@use 'sass:map';
@use '../../styles/abstracts/colors';
@use '../../styles/abstracts/maps';

.custom-modal {
background: colors.$color-primary;
left: 50%;
padding: map-get(maps.$spacing, 'lg');
padding: map.get(maps.$spacing, 'lg');
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('CustomModal', () => {
aria-labelledby="test-modal-title"
>
<div>Sisältöä tarvitaan</div>
</CustomModal>
</CustomModal>,
);
expect(baseElement).toMatchSnapshot();
});
Expand All @@ -32,7 +32,7 @@ describe('CustomModal', () => {
aria-labelledby="test-modal-title"
>
<div>Lisää tekstiä</div>
</CustomModal>
</CustomModal>,
);
expect(baseElement).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('CustomSwitch', () => {
errorLabel="test-error-label"
value={true}
disabled={true}
></CustomSwitch>
></CustomSwitch>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand All @@ -25,7 +25,7 @@ describe('CustomSwitch', () => {
<CustomSwitch
leftLabel="anotherLeftLabel"
rightLabel="anotherRightLabel"
/>
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('CustomTextField', () => {
label="test label"
value="wrong test value"
error={true}
/>
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const DropDownMenuButton: FC<DropDownMenuButtonProps> = ({

const handleMenuItemClick = (
event: React.MouseEvent<HTMLLIElement, MouseEvent>,
index: number
index: number,
) => {
setSelectedIndex(index);
setOpen(false);
Expand Down Expand Up @@ -110,7 +110,7 @@ export const DropDownMenuButton: FC<DropDownMenuButtonProps> = ({
<ListItemIcon>{option.icon}</ListItemIcon>
<ListItemText>{option.label}</ListItemText>
</MenuItem>
)
),
)}
</MenuList>
</ClickAwayListener>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('LabeledTextField', () => {
it('should render correctly with text', () => {
const tree = renderer
.create(
<LabeledTextField id="test-id" label="test label" value="test value" />
<LabeledTextField id="test-id" label="test label" value="test value" />,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand All @@ -21,7 +21,7 @@ describe('LabeledTextField', () => {
placeholder="placeholder expected to appear between label and field"
value="wrong test value"
error={true}
/>
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('LangSelector', () => {
changeLang={changeLang}
langSelectorAriaLabel="aria-label"
getCurrentLang={getCurrentLang}
/>
/>,
)
.toJSON();

Expand All @@ -30,7 +30,7 @@ describe('LangSelector', () => {
changeLang={changeLang}
langSelectorAriaLabel="aria-label"
getCurrentLang={getCurrentLang}
/>
/>,
);

expect(screen.getByText('lang.fi')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('LanguageSelect', () => {
excludedLanguage="FI"
primaryLanguages={['SV']}
translateLanguage={jest.fn((l: string) => l)}
/>
/>,
)
.toJSON();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ComboBox, sortOptionsByLabels } from '../ComboBox/ComboBox';

export const languageToComboBoxOption = (
translate: (l: string) => string,
lang: string
lang: string,
): ComboBoxOption => ({
label: translate(lang),
value: lang,
Expand Down Expand Up @@ -51,7 +51,7 @@ export const LanguageSelect = ({
primaryLanguages
?.filter((language) => includedLanguages.includes(language))
.map((language) =>
languageToComboBoxOption(translateLanguage, language)
languageToComboBoxOption(translateLanguage, language),
) || [];

const secondaryOptions: Array<ComboBoxOption> = includedLanguages
Expand Down
Loading

0 comments on commit de8d3a4

Please sign in to comment.