-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more tests for data page and setup for other pages
- Loading branch information
Flaminia Cavallo
authored and
Flaminia Cavallo
committed
Jul 25, 2024
1 parent
ad71e7a
commit 01b06b2
Showing
12 changed files
with
457 additions
and
265 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
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
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,62 +1,68 @@ | ||
import { faker } from '@faker-js/faker' | ||
import {getReportText} from "./submit-modal"; | ||
import { getReportText } from './submit-modal' | ||
|
||
describe('getReportText', () => { | ||
it('returns the report name', () => { | ||
const name = faker.word.noun() | ||
const orgUnits = [] | ||
const periods = [] | ||
const result = getReportText({name, orgUnits, periods}) | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain(name) | ||
}) | ||
|
||
it('returns the org unit count when there is one', () => { | ||
const name = faker.word.noun() | ||
const orgUnits = ["anOrgUnit"] | ||
const orgUnits = ['anOrgUnit'] | ||
const periods = [] | ||
const result = getReportText({name, orgUnits, periods}) | ||
expect(result).toContain("1 organisation unit") | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain('1 organisation unit') | ||
}) | ||
|
||
it('returns the org unit count when there is more than one', () => { | ||
const name = faker.word.noun() | ||
const orgUnitCounts = faker.number.int({min: 2, max: 5}) | ||
const orgUnitCounts = faker.number.int({ min: 2, max: 5 }) | ||
const orgUnits = Array(orgUnitCounts).fill('anOrgUnit') | ||
const periods = [] | ||
const result = getReportText({name, orgUnits, periods}) | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain(`${orgUnitCounts} organisation units`) | ||
}) | ||
|
||
it('returns the period when there is only one', () => { | ||
const name = faker.word.noun() | ||
const orgUnits = [] | ||
const periods = ['a period'] | ||
const result = getReportText({name, orgUnits, periods}) | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain(`1 period: a period`) | ||
}) | ||
|
||
it('returns the periods when there is two', () => { | ||
const name = faker.word.noun() | ||
const orgUnits = [] | ||
const periods = ['a period', 'another period'] | ||
const result = getReportText({name, orgUnits, periods}) | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain(`2 periods: a period, another period`) | ||
}) | ||
|
||
it('returns the periods when there is three', () => { | ||
const name = faker.word.noun() | ||
const orgUnits = [] | ||
const periods = ['a period', 'another period', 'one more period'] | ||
const result = getReportText({name, orgUnits, periods}) | ||
expect(result).toContain(`3 periods: a period, another period, one more period`) | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain( | ||
`3 periods: a period, another period, one more period` | ||
) | ||
}) | ||
|
||
it('returns the periods count when there is more than three', () => { | ||
const name = faker.word.noun() | ||
const orgUnits = [] | ||
const periodsCounts = faker.number.int({min: 4, max: 10}) | ||
const periodsCounts = faker.number.int({ min: 4, max: 10 }) | ||
const periods = Array(periodsCounts).fill('a period') | ||
const result = getReportText({name, orgUnits, periods}) | ||
expect(result).toContain(`3+ periods: a period, a period, a period, and ${periodsCounts -3} more`) | ||
const result = getReportText({ name, orgUnits, periods }) | ||
expect(result).toContain( | ||
`3+ periods: a period, a period, a period, and ${ | ||
periodsCounts - 3 | ||
} more` | ||
) | ||
}) | ||
}) |
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
Oops, something went wrong.