Skip to content

Commit

Permalink
test: add Unpublished to Collection.stories.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Oct 3, 2024
1 parent c20f84c commit ae29873
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/stories/collection/Collection.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WithLayout } from '../WithLayout'
import { WithLoggedInUser } from '../WithLoggedInUser'
import { CollectionMockRepository } from './CollectionMockRepository'
import { CollectionLoadingMockRepository } from './CollectionLoadingMockRepository'
import { UnpublishedCollectionMockRepository } from '@/stories/collection/UnpublishedCollectionMockRepository'

const meta: Meta<typeof Collection> = {
title: 'Pages/Collection',
Expand Down Expand Up @@ -59,6 +60,18 @@ export const LoggedIn: Story = {
/>
)
}
export const Unpublished: Story = {
decorators: [WithLoggedInUser],
render: () => (
<Collection
collectionRepository={new UnpublishedCollectionMockRepository()}
collectionId="collection"
created={false}
published={false}
collectionQueryParams={{ pageQuery: 1, searchQuery: undefined, typesQuery: undefined }}
/>
)
}

export const Created: Story = {
decorators: [WithLoggedInUser],
Expand Down
14 changes: 14 additions & 0 deletions src/stories/collection/UnpublishedCollectionMockRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CollectionMother } from '../../../tests/component/collection/domain/models/CollectionMother'
import { Collection } from '../../collection/domain/models/Collection'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'
import { CollectionMockRepository } from '@/stories/collection/CollectionMockRepository'

export class UnpublishedCollectionMockRepository extends CollectionMockRepository {
getById(_id: string): Promise<Collection> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(CollectionMother.createUnpublished())
}, FakerHelper.loadingTimout())
})
}
}

0 comments on commit ae29873

Please sign in to comment.