-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add stories for DataDimension component
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 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
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', | ||
} |