-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrapp mentions in special tags before creating an annotation
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import sinon from 'sinon'; | ||
|
||
import * as fixtures from '../../test/annotation-fixtures'; | ||
import { AnnotationsService, $imports } from '../annotations'; | ||
|
||
|
@@ -67,6 +69,8 @@ describe('AnnotationsService', () => { | |
selectTab: sinon.stub(), | ||
setExpanded: sinon.stub(), | ||
updateFlagStatus: sinon.stub(), | ||
defaultAuthority: sinon.stub().returns('hypothes.is'), | ||
isFeatureEnabled: sinon.stub().returns(false), | ||
}; | ||
|
||
setLoggedIn(true); | ||
|
@@ -506,6 +510,40 @@ describe('AnnotationsService', () => { | |
}); | ||
}); | ||
|
||
[ | ||
{ | ||
profile: { userid: 'acct:[email protected]' }, | ||
mentionsEnabled: false, | ||
expectedText: 'hello @bob', | ||
}, | ||
{ | ||
profile: { userid: 'acct:[email protected]' }, | ||
mentionsEnabled: true, | ||
expectedText: | ||
'hello <a data-hyp-mention="" data-userid="acct:[email protected]">@bob</a>', | ||
}, | ||
{ | ||
profile: { userid: 'acct:foo' }, | ||
mentionsEnabled: true, | ||
expectedText: | ||
'hello <a data-hyp-mention="" data-userid="acct:[email protected]">@bob</a>', | ||
}, | ||
].forEach(({ profile, mentionsEnabled, expectedText }) => { | ||
it('wraps mentions in tags when feature is enabled', async () => { | ||
fakeStore.isFeatureEnabled.returns(mentionsEnabled); | ||
fakeStore.profile.returns(profile); | ||
fakeStore.getDraft.returns({ text: 'hello @bob' }); | ||
|
||
await svc.save(fixtures.defaultAnnotation()); | ||
|
||
assert.calledWith( | ||
fakeApi.annotation.create, | ||
{}, | ||
sinon.match({ text: expectedText }), | ||
); | ||
}); | ||
}); | ||
|
||
context('successful save', () => { | ||
it('copies over internal app-specific keys to the annotation object', () => { | ||
fakeMetadata.isSaved.returns(true); | ||
|