-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove "Bachelor" section from "Education" (#212)
- Loading branch information
Showing
18 changed files
with
89 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 18 additions & 17 deletions
35
src/__tests__/components/Education/EducationItem.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
/// <reference types="jest" /> | ||
import '@testing-library/jest-dom' | ||
import * as React from 'react' | ||
import { shallow, ShallowWrapper } from 'enzyme' | ||
import EducationItem from '../../../components/Education/EducationItem' | ||
import { useTranslation } from '../../__mocks__/react-i18next' | ||
import configureMockStore from 'redux-mock-store' | ||
import { Provider } from 'react-redux' | ||
import { render } from '@testing-library/react' | ||
|
||
let tMock | ||
import EducationItem from '../../../components/Education/EducationItem' | ||
import { testEducationItem } from './scripts' | ||
|
||
beforeAll(() => { | ||
tMock = useTranslation().t | ||
}) | ||
const mockStore = configureMockStore() | ||
const store = mockStore({}) | ||
|
||
test('should render EducationItem correctly', () => { | ||
const wrapper: ShallowWrapper = shallow(<EducationItem | ||
from={2019} | ||
to={2020} | ||
title="test-title" | ||
/>) | ||
expect(wrapper).toMatchSnapshot() | ||
expect(tMock).toHaveBeenCalledTimes(2) | ||
expect(tMock).toHaveBeenCalledWith('business-card-education-university-title') | ||
expect(tMock).toHaveBeenCalledWith('business-card-education-university-speciality') | ||
const { container } = render( | ||
<Provider store={store}> | ||
<EducationItem | ||
from={2019} | ||
to={2020} | ||
title="test-title" | ||
/> | ||
</Provider> | ||
) | ||
testEducationItem(container, 2019, 2020, 'test-title') | ||
}) |
31 changes: 17 additions & 14 deletions
31
src/__tests__/components/Education/EducationMain.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
/// <reference types="jest" /> | ||
import '@testing-library/jest-dom' | ||
import * as React from 'react' | ||
import { shallow, ShallowWrapper } from 'enzyme' | ||
import EducationMain from '../../../components/Education/EducationMain' | ||
import { useTranslation } from '../../__mocks__/react-i18next' | ||
import configureMockStore from 'redux-mock-store' | ||
import { Provider } from 'react-redux' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
let tMock | ||
import EducationMain from '../../../components/Education/EducationMain' | ||
import { testEducationItem } from './scripts' | ||
|
||
beforeAll(() => { | ||
tMock = useTranslation().t | ||
}) | ||
const mockStore = configureMockStore() | ||
const store = mockStore({}) | ||
|
||
test('should render EducationItem correctly', () => { | ||
const wrapper: ShallowWrapper = shallow(<EducationMain />) | ||
expect(wrapper).toMatchSnapshot() | ||
expect(tMock).toHaveBeenCalledTimes(3) | ||
expect(tMock).toHaveBeenCalledWith('business-card-education-title') | ||
expect(tMock).toHaveBeenCalledWith('business-card-education-university-master') | ||
expect(tMock).toHaveBeenCalledWith('business-card-education-university-bachelor') | ||
render( | ||
<Provider store={store}> | ||
<EducationMain /> | ||
</Provider> | ||
) | ||
expect(screen.getByRole('heading', { level: 2 })) | ||
.toHaveTextContent('business-card-education-title') | ||
const listItem = screen.getByRole('listitem') | ||
testEducationItem(listItem, 2005, 2010, 'business-card-education-university-master') | ||
}) |
43 changes: 0 additions & 43 deletions
43
src/__tests__/components/Education/__snapshots__/EducationItem.spec.tsx.snap
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
src/__tests__/components/Education/__snapshots__/EducationMain.spec.tsx.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import '@testing-library/jest-dom' | ||
|
||
/* eslint-disable no-undef */ | ||
export function testEducationItem( | ||
container: HTMLElement, from: number, to: number, title: string) { | ||
const h4DateLocaleElements = container.querySelectorAll('div.timeline-image h4') | ||
expect(h4DateLocaleElements).toHaveLength(1) | ||
expect(h4DateLocaleElements.item(0)).toHaveTextContent(`${to}-${from}`) | ||
const h4TimelineElements = container.querySelectorAll('div.timeline-heading h4') | ||
expect(h4TimelineElements).toHaveLength(2) | ||
expect(h4TimelineElements.item(0)).toHaveTextContent('business-card-education-university-title') | ||
expect(h4TimelineElements.item(1)).toHaveTextContent(title) | ||
const pBodyElements = container.querySelectorAll('div.timeline-body p') | ||
expect(pBodyElements).toHaveLength(1) | ||
expect(pBodyElements.item(0)).toHaveTextContent('business-card-education-university-speciality') | ||
} | ||
/* eslint-enable */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,34 @@ | ||
/// <reference types="jest" /> | ||
import * as React from 'react' | ||
import { shallow, ShallowWrapper } from 'enzyme' | ||
import { DateLocale } from '../../../components/controls/DateLocale' | ||
import { useTranslation } from '../../__mocks__/react-i18next' | ||
import { render } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
|
||
let tMock | ||
import { DateLocale } from '../../../components/controls/DateLocale' | ||
import { Locale } from '../../../store/locale/types' | ||
|
||
beforeAll(() => { | ||
tMock = useTranslation().t | ||
test('should render correctly with month, year and non-JP locale', () => { | ||
const { container } = render( | ||
<DateLocale year={2022} month={1} locale={new Locale('en', 'EN')} /> | ||
) | ||
expect(container).toHaveTextContent('business-card-month-1 2022') | ||
}) | ||
|
||
interface DateLocaleFixture { | ||
title: string | ||
locale: string | ||
expect: (toDoubleByteSpy: jest.Mock<string, string[]>, year: number, month?: number) => void | ||
} | ||
test('should render correctly with year and non-JP locale', () => { | ||
const { container } = render( | ||
<DateLocale year={2001} locale={new Locale('en', 'EN')} /> | ||
) | ||
expect(container).toHaveTextContent('2001') | ||
}) | ||
|
||
new Array<DateLocaleFixture>({ | ||
title: 'JP', | ||
locale: 'jp', | ||
expect: (toDoubleByteSpy, year, month) => { | ||
expect(tMock).toHaveBeenCalledTimes(2) | ||
expect(tMock).toHaveBeenNthCalledWith(1, 'business-card-year-singular') | ||
expect(tMock).toHaveBeenNthCalledWith(2, `business-card-month-${month}`) | ||
expect(toDoubleByteSpy).toHaveBeenCalledWith(year.toString()) | ||
} | ||
}, { | ||
title: 'non-JP', | ||
locale: 'gb', | ||
expect: (toDoubleByteSpy, year, month) => { | ||
expect(tMock).toHaveBeenCalledTimes(1) | ||
expect(tMock).toHaveBeenCalledWith(`business-card-month-${month}`) | ||
expect(toDoubleByteSpy).not.toHaveBeenCalled() | ||
} | ||
}).forEach((f) => | ||
test(`should render DateLocale with month in ${f.title} locale correctly`, () => { | ||
const month = 1 | ||
const year = 2019 | ||
tMock.mockImplementation((k) => `${f.locale}-${k}`) | ||
const toDoubleByteSpy: jest.Mock<string, string[]> = jest.fn((k) => k) | ||
const wrapper: ShallowWrapper = shallow( | ||
<DateLocale | ||
converter={{ | ||
_convert: null, | ||
toDoubleByte: toDoubleByteSpy, | ||
toSingleByte: null | ||
}} | ||
locale={{ | ||
code: f.locale, | ||
title: '' | ||
}} | ||
month={month} | ||
year={year} | ||
/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
f.expect(toDoubleByteSpy, year, month) | ||
}) | ||
) | ||
test('should render correctly with month, year and JP locale', () => { | ||
const { container } = render( | ||
<DateLocale year={2012} month={4} locale={new Locale('jp', 'JP')} /> | ||
) | ||
expect(container).toHaveTextContent('2012business-card-year-singularbusiness-card-month-4') | ||
}) | ||
|
||
new Array<DateLocaleFixture>({ | ||
title: 'JP', | ||
locale: 'jp', | ||
expect: (toDoubleByteSpy, year) => { | ||
expect(tMock).toHaveBeenCalledTimes(1) | ||
expect(tMock).toHaveBeenCalledWith('business-card-year-singular') | ||
expect(tMock).not.toHaveBeenCalledWith(expect.stringMatching(/^business-card-month-.*$/)) | ||
expect(toDoubleByteSpy).toHaveBeenCalledWith(year.toString()) | ||
} | ||
}, { | ||
title: 'non-JP', | ||
locale: 'gb', | ||
expect: (toDoubleByteSpy, year) => { | ||
expect(tMock).not.toHaveBeenCalled() | ||
expect(toDoubleByteSpy).not.toHaveBeenCalled() | ||
} | ||
}).forEach((f) => | ||
test(`should render DateLocale without month in ${f.title} locale correctly`, () => { | ||
const year = 2019 | ||
tMock.mockImplementation((k) => `${f.locale}-${k}`) | ||
const toDoubleByteSpy = jest.fn((k) => k) | ||
const wrapper: ShallowWrapper = shallow( | ||
<DateLocale | ||
converter={{ | ||
_convert: null, | ||
toDoubleByte: toDoubleByteSpy, | ||
toSingleByte: null | ||
}} | ||
locale={{ | ||
code: f.locale, | ||
title: '' | ||
}} | ||
year={year} | ||
/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
f.expect(toDoubleByteSpy, year) | ||
}) | ||
) | ||
test('should render correctly with year and JP locale', () => { | ||
const { container } = render( | ||
<DateLocale year={2002} locale={new Locale('jp', 'JP')} /> | ||
) | ||
expect(container).toHaveTextContent('2002business-card-year-singular') | ||
}) |
33 changes: 0 additions & 33 deletions
33
src/__tests__/components/controls/__snapshots__/DateLocale.spec.tsx.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.