Skip to content

Commit

Permalink
test: Reorganize tests for getPaperDefinitionByFile
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Jul 30, 2024
1 parent 05d3ddb commit 034e854
Showing 1 changed file with 53 additions and 56 deletions.
109 changes: 53 additions & 56 deletions src/components/ModelSteps/Edit/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,76 +395,73 @@ describe('getPaperDefinitionByFile', () => {
})

describe('paperDefinition has a country defined', () => {
it('should return the paperDefinition "driver_license", with the country "fr" as default', () => {
const fakeFile = makeFakeFile({ qualificationLabel: 'driver_license' })
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})
describe('it should return fr driver_license', () => {
it('for undefined country in file', () => {
const fakeFile = makeFakeFile({ qualificationLabel: 'driver_license' })
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

it('should return the paperDefinition "driver_license", with the country "fr"', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'FR'
expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})

it('should return the paperDefinition "driver_license", with the country "fr" even when lowercase', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'fr'
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})

it('should return the paperDefinition "driver_license", with the country "fr" if undefined', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: undefined
it('for empty country in file', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: ''
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({
label: 'driver_license',
country: 'fr'
})
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})
it('for "FR" country in file', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'FR'
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

it('should return the paperDefinition "driver_license", with the country "foreign" if defined', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'EN'
expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({
label: 'driver_license',
country: 'foreign'
})
})
it('for "fr" country in file', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'fr'
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

it('should return the paperDefinition "driver_license", with the country "foreign" for unsupported country metadata', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'moon'
expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'foreign' })
})

it('should return the paperDefinition "driver_license", with the country "fr" if it empty in file', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: ''
describe('it should return foreign driver_license', () => {
it('for "EN" in file', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'EN'
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({
label: 'driver_license',
country: 'foreign'
})
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({
label: 'driver_license',
country: 'fr'
it('for unsupported country metadata', () => {
const fakeFile = makeFakeFile({
qualificationLabel: 'driver_license',
country: 'moon'
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({
label: 'driver_license',
country: 'foreign'
})
})
})
})
Expand Down

0 comments on commit 034e854

Please sign in to comment.