Browse Source
Merge pull request #3226 from Budibase/fix/3195
Fix for bindings not passing through falsy values
pull/3259/head
Michael Drury
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
13 additions and
1 deletions
-
packages/string-templates/src/helpers/index.js
-
packages/string-templates/test/basic.spec.js
|
|
@ -31,7 +31,7 @@ const HELPERS = [ |
|
|
} |
|
|
} |
|
|
// null/undefined values produce bad results
|
|
|
// null/undefined values produce bad results
|
|
|
if (value == null || typeof value !== "string") { |
|
|
if (value == null || typeof value !== "string") { |
|
|
return value || "" |
|
|
return value == null ? "" : value |
|
|
} |
|
|
} |
|
|
if (value && value.string) { |
|
|
if (value && value.string) { |
|
|
value = value.string |
|
|
value = value.string |
|
|
|
|
|
@ -125,6 +125,18 @@ describe("check the utility functions", () => { |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe("check falsy values", () => { |
|
|
|
|
|
it("should get a zero out when context contains it", async () => { |
|
|
|
|
|
const output = await processString("{{ number }}", { number: 0 }) |
|
|
|
|
|
expect(output).toEqual("0") |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("should get false out when context contains it", async () => { |
|
|
|
|
|
const output = await processString("{{ bool }}", { bool: false }) |
|
|
|
|
|
expect(output).toEqual("false") |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
describe("check manifest", () => { |
|
|
describe("check manifest", () => { |
|
|
it("should be able to retrieve the manifest", () => { |
|
|
it("should be able to retrieve the manifest", () => { |
|
|
const manifest = getManifest() |
|
|
const manifest = getManifest() |
|
|
|