Skip to content

Commit

Permalink
More WIP and debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
TrangPham committed Mar 11, 2024
1 parent 576db4b commit fbece4d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/controls/DatetimeControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@ import { render } from "../common/test-render"

import { screen } from "@testing-library/react"
import { datetimeSchema, datetimeUISchema, datetimeUISchemaWithRule } from "../testSchemas/datetimeSchema"
import { isDateTimeControl, rankWith } from "@jsonforms/core"

describe("DatetimeControlTester", () => {
test("tester works", () => {
const uiSchema = {
type: "Control",
scope: "#/properties/datetime",
}
const schema = {
type: "string",
title: "The Future is Now",
format: "date-time",
}
const context = {rootSchema: datetimeSchema, config: {}}

expect(rankWith(1, isDateTimeControl)(uiSchema, schema, context)).toBe(1)
})
})
describe("DatetimeControl", () => {
const timestamp = "2023-07-18T01:02:01.182Z"
const title = "The Future is Now"
Expand Down
39 changes: 36 additions & 3 deletions src/stories/controls/DatetimeControl.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { cellRegistryEntries, rendererRegistryEntries } from "../../renderers";
import { StorybookAntDJsonForm } from "../../common/StorybookAntDJsonForm";
import { datetimeSchema, datetimeUISchema } from "../../testSchemas/datetimeSchema";
import { JsonForms } from "@jsonforms/react";
import { DatetimeControl } from "../../controls/DatetimeControl";

const meta: Meta<typeof StorybookAntDJsonForm> = {
title: "Control/Datetime",
Expand All @@ -15,10 +16,14 @@ const meta: Meta<typeof StorybookAntDJsonForm> = {
]
},
argTypes: {
rendererRegistryEntries: {},
rendererRegistryEntries: { table: { disable: true } },
uiSchemaRegistryEntries: { table: { disable: true } },
jsonSchema: {
control: "object",
}
},
data: {table: {disable: true}},
config: {control: "object"},
onChange: {table: {disable: true, action: "on-change"}},
}
};

Expand All @@ -33,7 +38,7 @@ export const Datetime: Story = {
},
}

export const DateTimeControl: Story = {
export const DateTimeControlUsingJsonForms: Story = {
render: () => (
<JsonForms
data={{datetime: "2023-07-18T01:02:01.182Z"}}
Expand All @@ -42,4 +47,32 @@ export const DateTimeControl: Story = {
renderers={[...rendererRegistryEntries]}
/>
),
}

export const DateTimeControlComponent: Story = {
argTypes: {
rendererRegistryEntries: { table: { disable: true } },
uiSchemaRegistryEntries: { table: { disable: true } },
jsonSchema: {
control: "object",
},
data: {table: {disable: true}},
config: {control: "object"},
onChange: {table: {disable: true, action: "on-change"}},
},
render: () => (
<DatetimeControl
data="2023-07-18T01:02:01.182Z"
path="datetime"
schema={datetimeSchema}
handleChange={(result) => console.log(result)}
label="Datetime"
uischema={datetimeUISchema["elements"][0]}
errors=""
rootSchema={{}}
id=""
enabled={true}
visible={true}
/>
),
}

0 comments on commit fbece4d

Please sign in to comment.