-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(storybook): add PeerBandwidthTable.stories.js (#2095)
* chore: add PeerBandwidthTable.stories.js * chore: resolve lint failures * Update src/status/PeerBandwidthTable.stories.js Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * Update src/status/PeerBandwidthTable.stories.js Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * Update src/status/PeerBandwidthTable.js Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * test: lint fix --------- Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
71 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react' | ||
import PeerBandwidthTableComponent from './PeerBandwidthTable.js' | ||
import { Provider } from 'redux-bundler-react' | ||
import { composeBundlesRaw } from 'redux-bundler' | ||
|
||
const defaultState = { | ||
peerBandwidthPeers: [ | ||
{ | ||
id: 'peer1', | ||
bw: { | ||
rateIn: 1000, | ||
rateOut: 500, | ||
totalIn: 10000, | ||
totalOut: 5000 | ||
} | ||
}, | ||
{ | ||
id: 'peer2', | ||
bw: { | ||
rateIn: 10, | ||
rateOut: 5, | ||
totalIn: 10000, | ||
totalOut: 5000 | ||
} | ||
} | ||
], | ||
peerLocations: { | ||
peer1: { | ||
country_name: 'United States', | ||
country_code: 'US' | ||
}, | ||
peer2: { | ||
country_name: 'Canada', | ||
country_code: 'CA' | ||
} | ||
} | ||
} | ||
|
||
const getStore = composeBundlesRaw({ | ||
name: 'peerBandwidth', | ||
selectPeerBandwidthPeers: state => state.peerBandwidth.peerBandwidthPeers, | ||
selectPeerLocations: state => state.peerBandwidth.peerLocations, | ||
reducer: (state, { type, payload }) => state ?? defaultState | ||
}) | ||
const store = getStore({ peerBandwidth: defaultState }) | ||
|
||
/** | ||
* @type {import('@storybook/react').Meta} | ||
*/ | ||
export default { | ||
title: 'Status/PeerBandwidthTable', | ||
component: PeerBandwidthTableComponent, | ||
decorators: [ | ||
(Story) => ( | ||
<Provider store={store}> | ||
<Story/> | ||
</Provider> | ||
) | ||
] | ||
} | ||
|
||
/** | ||
* @type {import('@storybook/react').StoryObj} | ||
*/ | ||
export const PeerBandwidthTable = { | ||
args: { | ||
peerBandwidthPeers: defaultState.peerBandwidthPeers, | ||
peerLocations: defaultState.peerLocations | ||
} | ||
} |