Skip to content

Commit

Permalink
feat(package): added mention to the LinkType enum + specs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Jul 23, 2018
1 parent 5b2f91e commit aeb43af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/module/enum/linktype.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum LinkType {
URL = 'url',
HASHTAG = 'hashtag'
HASHTAG = 'hashtag',
MENTION = 'mention',
}
23 changes: 23 additions & 0 deletions src/module/service/ngx-linkifyjs.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {inject, TestBed} from '@angular/core/testing';
import * as linkify from 'linkifyjs';
// @ts-ignore
import * as hashtag from 'linkifyjs/plugins/hashtag';
// @ts-ignore
import * as mention from 'linkifyjs/plugins/mention';

import {NgxLinkifyjsService} from './ngx-linkifyjs.service';
import {Link, LinkType} from '../..';
Expand All @@ -12,6 +14,7 @@ describe('LibService', () => {

beforeAll(() => {
hashtag(linkify);
mention(linkify);
});

beforeEach(() => {
Expand Down Expand Up @@ -89,6 +92,26 @@ describe('LibService', () => {
expect(result.length).toEqual(2);
}));

it('should find 2 mention links', inject([NgxLinkifyjsService], (service: NgxLinkifyjsService) => {
const result: Link[] = service.find('Linkify needs @you and @someone else');
expect(result).toEqual(
[
{
type: LinkType.MENTION,
value: '@you',
href: '/you'
},
{
type: LinkType.MENTION,
value: '@someone',
href: '/someone'
}
]
);

expect(result.length).toEqual(2);
}));

// test function

it('should return true if a link is provided', inject([NgxLinkifyjsService], (service: NgxLinkifyjsService) => {
Expand Down

0 comments on commit aeb43af

Please sign in to comment.