Skip to content

Commit

Permalink
Add an extra test for diff-to-document
Browse files Browse the repository at this point in the history
  • Loading branch information
VasylMarchuk committed Oct 6, 2024
1 parent 2b7a8b7 commit 09577a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/diff-to-document.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { helper } from '@ember/component/helper';

const diffToDocument = helper(function diffToDocument([diff = '']: [string]) {
const diffToDocument = helper(function diffToDocument([diff = '']: [string | undefined]) {
const diffLines = diff.split('\n');

const current = [];
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/helpers/diff-to-document-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ module('Integration | Helper | diff-to-document', function (hooks) {
assert.dom('[data-test-current-document]').hasText(/^1234\n2345\n6789\n$/);
assert.dom('[data-test-original-document]').hasText(/^1234\n6789\n0123\n$/);
});

test('it does not break if passed an undefined diff', async function (assert) {
await render(hbs`
{{#let (diff-to-document undefined) as |doc|}}
<pre data-test-current-document>{{doc.current}}</pre>
<pre data-test-original-document>{{doc.original}}</pre>
{{/let}}
`);

assert.dom('[data-test-current-document]').hasText(/^$/);
assert.dom('[data-test-original-document]').hasText(/^$/);
});
});

0 comments on commit 09577a5

Please sign in to comment.