Skip to content

Commit

Permalink
test: add stories for DataDimension component
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Dec 13, 2024
1 parent 8ea2a39 commit 50892f2
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/__demo__/DataDimension.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { DataProvider } from '@dhis2/app-runtime'
import { ConfigProvider } from '@dhis2/app-service-config'
import React, { useState } from 'react'
import DataDimension from '../components/DataDimension/DataDimension.js'

const Wrapper = (story) => (
<ConfigProvider config={{ serverVersion: { major: 2, minor: 41 } }}>
<DataProvider
baseUrl="https://test.e2e.dhis2.org/analytics-41dev"
apiVersion="41"
>
{story()}
</DataProvider>
</ConfigProvider>
)

export default {
title: 'DataDimension',
decorators: [Wrapper],
}

export const NoneSelected = () => {
const [selected, setSelected] = useState([])

return (
<DataDimension
displayNameProp="displayName"
selectedDimensions={selected}
onSelect={(response) => setSelected(response.items)}
/>
)
}

NoneSelected.story = {
name: 'None selected',
}

export const WithInfoBoxMessage = () => {
const [selected, setSelected] = useState([])

return (
<DataDimension
displayNameProp="displayName"
selectedDimensions={selected}
onSelect={(response) => setSelected(response.items)}
infoBoxMessage={'Test message showing in the info box'}
/>
)
}

WithInfoBoxMessage.story = {
name: 'With info box message',
}

0 comments on commit 50892f2

Please sign in to comment.