Skip to content

Commit

Permalink
[fix] bug where an extra comma is added after final object (#65)
Browse files Browse the repository at this point in the history
* Failing test

* Fix bug where an extra comma is added after final object
  • Loading branch information
bantic authored Jan 10, 2025
1 parent a6df266 commit fd9e28c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/addon/components/entry-viewer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@displayOptions={{@displayOptions}}
@path={{@path}}
/>
{{#unless this.isLast}}
{{#unless @isLast}}
{{! In order for copy/paste to work, there cannot be extra whitespace around the delimiter }}
<span class="entry-delimiter" data-path={{concat @path "@" ","}}>,</span>
{{/unless}}
Expand Down
19 changes: 19 additions & 0 deletions test-app/tests/integration/components/json-viewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,23 @@ module('Integration | Component | json-viewer', function (hooks) {
assert.strictEqual(userSelectStyle, expected);
}
});

test('no comma after final object', async function (assert) {
this.set('json', {
obj: { foo: 'bar' },
});
await render(
hbs`<JsonViewer data-test-json-viewer-outer @json={{this.json}} />`,
);

assert
.dom('[data-path="$.obj>"]')
.containsText('}', 'object closing brace is present');
assert
.dom('[data-path="$.obj@,"]')
.doesNotExist('no comma after final object');
assert
.dom('[data-test-json-viewer-outer]')
.doesNotContainText(',', 'No comma appears in the output');
});
});

0 comments on commit fd9e28c

Please sign in to comment.