Skip to content

Commit e3e1030

Browse files
committed
added tests for the linkify plugin
1 parent 3d26acf commit e3e1030

File tree

1 file changed

+30
-0
lines changed
  • draft-js-linkify-plugin/src/Link/__test__

1 file changed

+30
-0
lines changed

draft-js-linkify-plugin/src/Link/__test__/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,34 @@ describe('Link', () => {
3232
const result = shallow(<Link decoratedText="https://www.draft-js-plugins.com/" />);
3333
expect(result).to.have.prop('href').to.contain('https://www.draft-js-plugins.com/');
3434
});
35+
36+
it('applies http prefix when none is supplied', () => {
37+
const result = shallow(<Link decoratedText="draft-js-plugins.com/" />);
38+
expect(result).to.have.prop('href').to.contain('http://draft-js-plugins.com/');
39+
});
40+
41+
it('does not apply a prefix when one is already supplied', () => {
42+
const result = shallow(<Link decoratedText="ftp://draft-js-plugins.com/" />);
43+
expect(result).to.have.prop('href').to.contain('ftp://draft-js-plugins.com/');
44+
});
45+
46+
it('generates correct href to localhost with port', () => {
47+
const result = shallow(<Link decoratedText="http://localhost:8000" />);
48+
expect(result).to.have.prop('href').to.contain('http://localhost:8000');
49+
});
50+
51+
it('generates mailto href when supplied with email', () => {
52+
const result = shallow(<Link decoratedText="name@example.com" />);
53+
expect(result).to.have.prop('href').to.contain('mailto:name@example.com');
54+
});
55+
56+
it('uses _self as the default target value', () => {
57+
const result = shallow(<Link />);
58+
expect(result).to.have.prop('target').to.contain('_self');
59+
});
60+
61+
it('applies custom target value', () => {
62+
const result = shallow(<Link target="_blank" />);
63+
expect(result).to.have.prop('target').to.contain('_blank');
64+
});
3565
});

0 commit comments

Comments
 (0)