diff options
author | Heinrich Lee Yu <hleeyu@gmail.com> | 2018-12-21 11:49:44 +0300 |
---|---|---|
committer | Heinrich Lee Yu <hleeyu@gmail.com> | 2019-01-07 06:01:51 +0300 |
commit | 12b3a203228cef5946f1c8dc740ba739b1aed797 (patch) | |
tree | 193db469124d8dcd73b94f8f3dc09e9ae4490f14 /spec/javascripts | |
parent | b83be5032716548ea9d738a03e0a20f660dc04ac (diff) |
CE backport for `reference` in gfm_autocomplete
Currently not used by any CE code
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/gfm_auto_complete_spec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/javascripts/gfm_auto_complete_spec.js b/spec/javascripts/gfm_auto_complete_spec.js index 6f414c8ccf1..a14031f43ed 100644 --- a/spec/javascripts/gfm_auto_complete_spec.js +++ b/spec/javascripts/gfm_auto_complete_spec.js @@ -205,4 +205,40 @@ describe('GfmAutoComplete', function() { expect(GfmAutoComplete.isLoading({ title: 'Foo' })).toBe(false); }); }); + + describe('Issues.insertTemplateFunction', function() { + it('should return default template', function() { + expect(GfmAutoComplete.Issues.insertTemplateFunction({ id: 5, title: 'Some Issue' })).toBe( + '${atwho-at}${id}', // eslint-disable-line no-template-curly-in-string + ); + }); + + it('should return reference when reference is set', function() { + expect( + GfmAutoComplete.Issues.insertTemplateFunction({ + id: 5, + title: 'Some Issue', + reference: 'grp/proj#5', + }), + ).toBe('grp/proj#5'); + }); + }); + + describe('Issues.templateFunction', function() { + it('should return html with id and title', function() { + expect(GfmAutoComplete.Issues.templateFunction({ id: 5, title: 'Some Issue' })).toBe( + '<li><small>5</small> Some Issue</li>', + ); + }); + + it('should replace id with reference if reference is set', function() { + expect( + GfmAutoComplete.Issues.templateFunction({ + id: 5, + title: 'Some Issue', + reference: 'grp/proj#5', + }), + ).toBe('<li><small>grp/proj#5</small> Some Issue</li>'); + }); + }); }); |