-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MajorKeys: Fix wikimedia_common keys (#952)
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/components/FeaturePanel/Climbing/utils/__tests__/photo.test.ts
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,38 @@ | ||
import { getNextWikimediaCommonsIndex } from '../photo'; | ||
import { FeatureTags } from '../../../../../services/types'; | ||
|
||
describe('getNextWikimediaCommonsIndex', () => { | ||
it('should return 0 when there are no wikimedia_commons keys', () => { | ||
const tags: FeatureTags = {}; | ||
expect(getNextWikimediaCommonsIndex(tags)).toBe(0); | ||
}); | ||
|
||
it('should return 1 when there is one wikimedia_commons key', () => { | ||
const tags: FeatureTags = { wikimedia_commons: 'File:example.jpg' }; | ||
expect(getNextWikimediaCommonsIndex(tags)).toBe(1); | ||
}); | ||
|
||
it('should return the next index when there are multiple wikimedia_commons keys', () => { | ||
const tags: FeatureTags = { | ||
wikimedia_commons: 'File:example1.jpg', | ||
'wikimedia_commons:2': 'File:example2.jpg', | ||
}; | ||
expect(getNextWikimediaCommonsIndex(tags)).toBe(2); | ||
}); | ||
|
||
it('should handle non-numeric wikimedia_commons keys correctly', () => { | ||
const tags: FeatureTags = { | ||
wikimedia_commons: 'File:example1.jpg', | ||
'wikimedia_commons:path': 'some/path', | ||
}; | ||
expect(getNextWikimediaCommonsIndex(tags)).toBe(1); | ||
}); | ||
|
||
it('should handle gaps in the sequence of wikimedia_commons keys', () => { | ||
const tags: FeatureTags = { | ||
wikimedia_commons: 'File:example1.jpg', | ||
'wikimedia_commons:3': 'File:example3.jpg', | ||
}; | ||
expect(getNextWikimediaCommonsIndex(tags)).toBe(3); | ||
}); | ||
}); |
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