Fixing issue with regex helper - escape test used the word 'test' a lot which breaks the helper.

This commit is contained in:
mike12345567 2021-02-02 18:01:41 +00:00
parent b19c906572
commit 5dd11ddcc5
1 changed files with 9 additions and 9 deletions

View File

@ -4,15 +4,15 @@ const {
describe("Handling context properties with spaces in their name", () => { describe("Handling context properties with spaces in their name", () => {
it("should allow through literal specifiers", async () => { it("should allow through literal specifiers", async () => {
const output = await processString("test {{ [test thing] }}", { const output = await processString("test {{ [one thing] }}", {
"test thing": 1 "one thing": 1
}) })
expect(output).toBe("test 1") expect(output).toBe("test 1")
}) })
it("should convert to dot notation where required", async () => { it("should convert to dot notation where required", async () => {
const output = await processString("test {{ test[0] }}", { const output = await processString("test {{ one[0] }}", {
test: [2] one: [2]
}) })
expect(output).toBe("test 2") expect(output).toBe("test 2")
}) })
@ -25,9 +25,9 @@ describe("Handling context properties with spaces in their name", () => {
}) })
it("should be able to handle an object with layers that requires escaping", async () => { it("should be able to handle an object with layers that requires escaping", async () => {
const output = await processString("testcase {{ testing.[test case] }}", { const output = await processString("testcase {{ thing.[one case] }}", {
testing: { thing: {
"test case": 1 "one case": 1
} }
}) })
expect(output).toBe("testcase 1") expect(output).toBe("testcase 1")
@ -52,10 +52,10 @@ describe("attempt some complex problems", () => {
it("should be able to process an odd string produced by builder", async () => { it("should be able to process an odd string produced by builder", async () => {
const context = { const context = {
"c306d140d7e854f388bae056db380a0eb": { "c306d140d7e854f388bae056db380a0eb": {
"test prop": "test", "one prop": "test",
} }
} }
const hbs = "null{{ [c306d140d7e854f388bae056db380a0eb].[test prop] }}" const hbs = "null{{ [c306d140d7e854f388bae056db380a0eb].[one prop] }}"
const output = await processString(hbs, context) const output = await processString(hbs, context)
expect(output).toBe("nulltest") expect(output).toBe("nulltest")
}) })