-
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.
- Loading branch information
1 parent
fa2e504
commit 1c6859f
Showing
3 changed files
with
5 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,5 @@ | ||
import { sortPhotoList, usePhotoItems } from './composable'; | ||
|
||
describe('composable', () => { | ||
describe('sortPhotoList', () => { | ||
it('returns undefined for null or undefined photoList', () => { | ||
expect(sortPhotoList(undefined)).toBeUndefined(); | ||
expect(sortPhotoList(null)).toBeUndefined(); | ||
}); | ||
|
||
it('returns original list if no JOIN items are present', () => { | ||
const photoList = [{ type: 'PHOTO', date: '2023-12-15' }]; | ||
expect(sortPhotoList(photoList)).toEqual(photoList); | ||
}); | ||
|
||
const createPhotoList = ({ | ||
type, | ||
datetime, | ||
}: { type: 'PHOTO' | 'JOIN'; datetime: string }): ReturnType< | ||
typeof usePhotoItems | ||
>['photoItemList'] => { | ||
return { | ||
type, | ||
datetime: { | ||
date: { | ||
year: datetime.slice(0, 4), | ||
month: datetime.slice(5, 7), | ||
day: datetime.slice(8, 10), | ||
}, | ||
time: { | ||
hour: datetime.slice(11, 13), | ||
minute: datetime.slice(14, 16), | ||
second: 0, | ||
millisecond: 0, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
it('correctly rearranges list with JOIN items', () => { | ||
const photoList = [ | ||
createPhotoList({ type: 'PHOTO', datetime: '2023-12-17T00:00' }), | ||
createPhotoList({ type: 'JOIN', datetime: '2023-12-16T00:00' }), | ||
createPhotoList({ type: 'JOIN', datetime: '2023-12-15T00:00' }), | ||
]; | ||
console.log(photoList); | ||
const expectedResult = [ | ||
createPhotoList({ type: 'JOIN', datetime: '2023-12-16T00:00' }), | ||
createPhotoList({ type: 'PHOTO', datetime: '2023-12-17T00:00' }), | ||
createPhotoList({ type: 'JOIN', datetime: '2023-12-15T00:00' }), | ||
]; | ||
expect(sortPhotoList(photoList)).toEqual(expectedResult); | ||
}); | ||
it('should be defined', () => { | ||
expect(true).toBeTruthy(); | ||
}); | ||
}); |
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