Skip to content

Commit

Permalink
exported and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
newhouse committed Jun 21, 2022
1 parent 0bb7130 commit 1d08e40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function jsonReplacer(name, value) {
// return addSpecialTags(value)
}

function enumToJsonFriendly(str) {
export function enumToJsonFriendly(str) {
return (
str
// { foo: BAR } => { foo: "BAR" }
Expand Down
17 changes: 17 additions & 0 deletions test/src/lib/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ describe('common', function () {
unwindTags = common.__get__('unwindTags')
})

describe('enumToJsonFriendly', function () {
it('works', function () {
const pairs = [
['{foo: BAR, no: "change"}', '{foo: "BAR", no: "change"}'],
[
'{foo: [BAR, BAZ], no: "change"}',
'{foo: ["BAR", "BAZ"], no: "change"}',
],
['{no: "change"}', '{no: "change"}'],
]

for (const [input, output] of pairs) {
expect(common.enumToJsonFriendly(input)).to.eql(output)
}
})
})

describe('unwindTags', function () {
it('works', function () {
const pairs = [
Expand Down

0 comments on commit 1d08e40

Please sign in to comment.