-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[accel-web] fix namespace bug in formFor()
- Loading branch information
Showing
4 changed files
with
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"accel-web": patch | ||
--- | ||
|
||
Fixed the issue where the namespace passed to formFor() was not being reflected correctly. |
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,13 @@ | ||
--- | ||
import { FormModel } from "accel-record"; | ||
import { attributes } from "accel-record/attributes"; | ||
import { formFor } from "accel-web"; | ||
class SampleForm extends FormModel { | ||
count = attributes.integer(0); | ||
} | ||
const form = SampleForm.build({}); | ||
const { Label } = formFor(form, { namespace: "q" }); | ||
--- | ||
|
||
<Label for="count" /> |
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 |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import { experimental_AstroContainer as AstroContainer } from "astro/container"; | ||
import MyForm from "./MyForm.astro"; | ||
import MyFormWithNamespace from "./MyFormWithNamespace.astro"; | ||
|
||
test("formFor() with FormModel", async () => { | ||
const container = await AstroContainer.create(); | ||
const result = await container.renderToString(MyForm); | ||
|
||
expect(result).toContain('htmlFor="sampleForm.count"'); | ||
}); | ||
|
||
test("formFor() with namespace", async () => { | ||
const container = await AstroContainer.create(); | ||
const result = await container.renderToString(MyFormWithNamespace); | ||
|
||
expect(result).toContain('htmlFor="q.count"'); | ||
}); |