-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
1 changed file
with
41 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,41 @@ | ||
import { CreateRuleQuery, TypedDIDValidationQuery, TypedDIDValidationResponse } from "@/lib/infrastructure/data/view-model/create-rule"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { fixtureDIDLongViewModel, fixtureRSEAccountUsageLimitViewModel, mockUseComDOM } from "test/fixtures/table-fixtures"; | ||
import { CreateRule as CR} from "../Pages/Rule/CreateRule.stories"; | ||
|
||
export default { | ||
title: 'Demos/03_CreateRule', | ||
component: CR, | ||
} as Meta<typeof CR>; | ||
|
||
type Story = StoryObj<typeof CR> | ||
|
||
export const CreateRule: Story = { | ||
args: { | ||
onSubmit: (query: CreateRuleQuery) => { | ||
return Promise.resolve({ | ||
success: true, | ||
}) | ||
}, | ||
didListComDOM: mockUseComDOM(Array.from({ length: 100 }, () => fixtureDIDLongViewModel())), | ||
didValidation: (query: TypedDIDValidationQuery) => { | ||
// if the DID contains the string "error", it will be added to the error list | ||
var localErrorDIDs: TypedDIDValidationResponse = { ErrorList: [] } | ||
query.DIDList.map((DID: string, index: number) => { | ||
if (DID.includes("error")) { | ||
localErrorDIDs.ErrorList.push({ DID: DID, ErrorCodes: [421], Message: "This DID is invalid" }) | ||
} | ||
}) | ||
// if the error list is empty, the promise will resolve, otherwise it will reject | ||
if (localErrorDIDs.ErrorList.length === 0) { | ||
return Promise.resolve(localErrorDIDs) | ||
} | ||
else { | ||
return Promise.reject(localErrorDIDs) | ||
} | ||
}, | ||
rseListComDOM: mockUseComDOM(Array.from({ length: 100 }, () => fixtureRSEAccountUsageLimitViewModel())), | ||
|
||
} | ||
} | ||
|