Skip to content

Commit

Permalink
fixes tests for invalid links
Browse files Browse the repository at this point in the history
The invalid link tests were still expecting the link-parsing to be
performed during the validation function, but that responsibility was
moved to QuillJS. This commit adjusts the tests to look for the new
class.

:warning: This means we don't have any actual tests for link validation
in our custom link class.
  • Loading branch information
mattoberle committed Apr 9, 2021
1 parent 9d793f7 commit c2452a8
Showing 1 changed file with 4 additions and 85 deletions.
89 changes: 4 additions & 85 deletions lib/validators/built-in/invalid-links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,70 +44,10 @@ describe('validators: invalid-links', () => {
})).toEqual([]);
});

test('passes if field with hash link', () => {
test('fails if link class="kiln-link-invalid"', () => {
expect(fn({
components: {
[uri]: { a: '<a href="#my-anchor-link">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
},
schemas: {
[name]: {
a: {
_has: ['text']
}
}
}
})).toEqual([]);
});

test('passes if field with mailto link', () => {
expect(fn({
components: {
[uri]: { a: '<a href="mailto:[email protected]">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
},
schemas: {
[name]: {
a: {
_has: ['text']
}
}
}
})).toEqual([]);
});

test('passes if field with ftp link', () => {
expect(fn({
components: {
[uri]: { a: '<a href="ftp://1.1.1.1:21/test">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
},
schemas: {
[name]: {
a: {
_has: ['text']
}
}
}
})).toEqual([]);
});

test('passes if field with relative link', () => {
expect(fn({
components: {
[uri]: { a: '<a href="/subscribe">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
},
schemas: {
[name]: {
a: {
_has: ['text']
}
}
}
})).toEqual([]);
});

test('fails if space in mailto', () => {
expect(fn({
components: {
[uri]: { a: '<a href="mailto: [email protected]">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
[uri]: { a: '<a href="invalid" class="kiln-link-invalid">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
},
schemas: {
[name]: {
Expand All @@ -123,31 +63,10 @@ describe('validators: invalid-links', () => {
preview: 'Lorem ipsum dolor sit amet…'
}]);
});

test('fails if field with invalid link', () => {
expect(fn({
components: {
[uri]: { a: '<a href="http://one two three">Lorem ipsum dolor sit amet</a>, consectetur adipisicing elit' }
},
schemas: {
[name]: {
a: {
_has: ['text']
}
}
}
})).toEqual([{
uri,
field: 'a',
location: 'Paragraph',
preview: 'Lorem ipsum dolor sit amet…'
}]);
});

test('fails if mixed valid/invalid links', () => {
expect(fn({
components: {
[uri]: { a: '<a href="http://example.com">valid</a>, consectetur <a href="http://example com">invalid</a>' }
[uri]: { a: '<a href="">valid</a>, consectetur <a href="" class="kiln-link-invalid">invalid</a>' }
},
schemas: {
[name]: {
Expand All @@ -167,7 +86,7 @@ describe('validators: invalid-links', () => {
test('fails if multiple invalid links', () => {
expect(fn({
components: {
[uri]: { a: '<a href="http://bad one">one</a>, consectetur <a href="http://bad two">two</a>' }
[uri]: { a: '<a href="" class="kiln-link-invalid">one</a>, consectetur <a href="" class="kiln-link-invalid">two</a>' }
},
schemas: {
[name]: {
Expand Down

0 comments on commit c2452a8

Please sign in to comment.