-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/615 long provider names #677
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { cleanup, render, screen } from '@testing-library/react'; | ||
import { formatProvidersSorted, getFeedTitleElement } from '.'; | ||
import { | ||
type GTFSFeedType, | ||
type GTFSRTFeedType, | ||
} from '../../services/feeds/utils'; | ||
import { type TFunction } from 'i18next'; | ||
|
||
const mockFeed: GTFSFeedType = { | ||
id: 'mdb-x', | ||
data_type: 'gtfs', | ||
status: 'active', | ||
created_at: undefined, | ||
external_ids: [ | ||
{ | ||
external_id: 'x', | ||
source: 'mdb', | ||
}, | ||
], | ||
provider: 'DPN, AVL, CFL, CFLBus, RGTR, TICE, TRAM', | ||
feed_name: 'Aggregated Luxembourg - OpenOV', | ||
note: '', | ||
feed_contact_email: '', | ||
source_info: { | ||
producer_url: 'http://fake.zip', | ||
authentication_type: 0, | ||
authentication_info_url: '', | ||
api_key_parameter_name: '', | ||
license_url: 'http://fake/LICENSE.TXT', | ||
}, | ||
locations: [ | ||
{ | ||
country_code: 'BE', | ||
}, | ||
{ | ||
country_code: 'DE', | ||
}, | ||
{ | ||
country_code: 'FR', | ||
}, | ||
], | ||
latest_dataset: { | ||
id: '1', | ||
hosted_url: 'https://fake.zip', | ||
downloaded_at: '2024-07-03T17:38:24.963131Z', | ||
hash: 'x', | ||
}, | ||
}; | ||
|
||
const mockFeedOneProvider = { | ||
...mockFeed, | ||
provider: 'AVL', | ||
}; | ||
|
||
const mockFeedRT: GTFSRTFeedType = { | ||
id: 'mdb-x', | ||
data_type: 'gtfs_rt', | ||
status: 'active', | ||
external_ids: [ | ||
{ | ||
external_id: 'x', | ||
source: 'mdb', | ||
}, | ||
], | ||
provider: | ||
'SeaLink Pine Harbour, Waikato Regional Council, Pavlovich Transport Solutions, AT Metro', | ||
feed_name: 'Auckland Transport Developer', | ||
note: '', | ||
feed_contact_email: '', | ||
source_info: { | ||
producer_url: 'https://api.fake/vehiclelocations', | ||
authentication_type: 2, | ||
authentication_info_url: 'https://fake.govt.nz/', | ||
api_key_parameter_name: 'sub', | ||
license_url: 'https://fake/', | ||
}, | ||
locations: [ | ||
{ | ||
country_code: 'NZ', | ||
}, | ||
], | ||
entity_types: ['vp'], | ||
feed_references: ['mdb-y'], | ||
}; | ||
|
||
describe('Feed page', () => { | ||
afterEach(cleanup); | ||
|
||
it('should format the providers correctly', () => { | ||
const formattedProviders = formatProvidersSorted(mockFeed?.provider ?? ''); | ||
expect(formattedProviders).toEqual([ | ||
'AVL', | ||
'CFL', | ||
'CFLBus', | ||
'DPN', | ||
'RGTR', | ||
'TICE', | ||
'TRAM', | ||
]); | ||
}); | ||
|
||
it('should format the page title correctly when there are more than one and gtfs', () => { | ||
const mockT = jest.fn((key) => key) as unknown as TFunction< | ||
'feeds', | ||
undefined | ||
>; | ||
const formattedProviders = formatProvidersSorted(mockFeed?.provider ?? ''); | ||
render(getFeedTitleElement(formattedProviders, mockFeed, mockT)); | ||
expect(screen.getByText('AVL')).toBeTruthy(); | ||
expect(screen.getByText('+6 common:others')).toBeTruthy(); | ||
}); | ||
|
||
it('should format the page title correctly when there are more than one and gtfs_rt', () => { | ||
const mockT = jest.fn((key) => key) as unknown as TFunction< | ||
'feeds', | ||
undefined | ||
>; | ||
const formattedProviders = formatProvidersSorted( | ||
mockFeedRT?.provider ?? '', | ||
); | ||
render(getFeedTitleElement(formattedProviders, mockFeedRT, mockT)); | ||
expect( | ||
screen.getByText('AT Metro - Auckland Transport Developer'), | ||
).toBeTruthy(); | ||
expect(screen.getByText('+3 common:others')).toBeTruthy(); | ||
}); | ||
|
||
it('should format the page title correctly when there is only one provider', () => { | ||
const mockT = jest.fn((key) => key) as unknown as TFunction< | ||
'feeds', | ||
undefined | ||
>; | ||
const formattedProviders = formatProvidersSorted( | ||
mockFeedOneProvider?.provider ?? '', | ||
); | ||
render(getFeedTitleElement(formattedProviders, mockFeedOneProvider, mockT)); | ||
expect(screen.getByText('AVL')).toBeTruthy(); | ||
expect(screen.queryByText('+')).toBeNull(); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By having test files that focus on the component, it will reduce the amount of Cypress tests we need to write