Skip to content

Commit

Permalink
fix(yaml): fix sortKey error message (#5873)
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
timreichen authored Sep 3, 2024
1 parent 8abff45 commit d01e301
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion yaml/_dumper_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ export class DumperState {
} else if (this.sortKeys) {
// Something is wrong
throw new TypeError(
'"sortKeys" must be a boolean or a function: received ${typeof this.sortKeys}',
`"sortKeys" must be a boolean or a function: received ${typeof this
.sortKeys}`,
);
}

Expand Down
6 changes: 6 additions & 0 deletions yaml/stringify_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,12 @@ Deno.test("stringify() changes the key order when the sortKeys option is specifi
1.0.10: null
`,
);

assertThrows(
() => stringify(object, { sortKeys: "true" as unknown as boolean }),
TypeError,
'"sortKeys" must be a boolean or a function: received string',
);
});

Deno.test("stringify() changes line wrap behavior based on lineWidth option", () => {
Expand Down

0 comments on commit d01e301

Please sign in to comment.