-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ACC-1682] Add HalFormsTemplateBuilder#fromTemplate method
Add ability to easily create a builder from an existing hal forms template, to modify the template when it's necessary
- Loading branch information
1 parent
d45ddbe
commit 2ec2022
Showing
2 changed files
with
28 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,16 @@ | ||
import buildTemplate, { HalFormsTemplateBuilder } from "../src/builder"; | ||
|
||
describe("HalFormsTemplateBuilder", () => { | ||
it("#fromTemplate", () => { | ||
const original = buildTemplate("GET", "/") | ||
.withContentType("application/json") | ||
.addProperty("xyz", p => p.withPrompt("Test")); | ||
|
||
const fromTemplate = HalFormsTemplateBuilder.fromTemplate(original); | ||
|
||
expect(fromTemplate.contentType).toEqual("application/json"); | ||
expect(fromTemplate.properties).toHaveLength(1); | ||
expect(fromTemplate.properties[0]?.name).toEqual("xyz"); | ||
expect(fromTemplate.properties[0]?.prompt).toEqual("Test"); | ||
}) | ||
}); |
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