Skip to content

Commit

Permalink
enforce prettier in linter, use default rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jun 3, 2018
1 parent 142eed2 commit 9908711
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@
"class-methods-use-this": [
"off"
],
"import/extensions": [
"off"
],
"import/no-extraneous-dependencies": [
"error",
{
Expand All @@ -136,7 +133,8 @@
],
"import/named": [
"error"
]
],
"prettier/prettier": "error"
}
},
"prettier": {
Expand Down
43 changes: 30 additions & 13 deletions test/unit/theme/base/tooltip.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,78 @@
import Quill from '../../../../core';
import { BaseTooltip } from '../../../../themes/base'
import { BaseTooltip } from '../../../../themes/base';

class Tooltip extends BaseTooltip {
}
class Tooltip extends BaseTooltip {}

Tooltip.TEMPLATE = '<input type="text">';

describe('BaseTooltip', function() {
describe('save', function() {
beforeEach(function() {
this.quill = this.initialize(Quill, '');
this.tooltip = new Tooltip(this.quill)
this.tooltip = new Tooltip(this.quill);
});

it('converts youtube video url to embedded', function() {
insertVideo(this.tooltip, 'http://youtube.com/watch?v=QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain('http://www.youtube.com/embed/QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain(
'http://www.youtube.com/embed/QHH3iSeDBLo',
);
});

it('converts www.youtube video url to embedded', function() {
insertVideo(this.tooltip, 'http://www.youtube.com/watch?v=QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain('http://www.youtube.com/embed/QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain(
'http://www.youtube.com/embed/QHH3iSeDBLo',
);
});

it('converts m.youtube video url to embedded', function() {
insertVideo(this.tooltip, 'http://m.youtube.com/watch?v=QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain('http://www.youtube.com/embed/QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain(
'http://www.youtube.com/embed/QHH3iSeDBLo',
);
});

it('preserves youtube video url protocol', function() {
insertVideo(this.tooltip, 'https://m.youtube.com/watch?v=QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain('https://www.youtube.com/embed/QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain(
'https://www.youtube.com/embed/QHH3iSeDBLo',
);
});

it('uses https as default youtube video url protocol', function() {
insertVideo(this.tooltip, 'youtube.com/watch?v=QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain('https://www.youtube.com/embed/QHH3iSeDBLo');
expect(this.container.querySelector('.ql-video').src).toContain(
'https://www.youtube.com/embed/QHH3iSeDBLo',
);
});

it('converts vimeo video url to embedded', function() {
insertVideo(this.tooltip, 'http://vimeo.com/47762693');
expect(this.container.querySelector('.ql-video').src).toContain('http://player.vimeo.com/video/47762693/');
expect(this.container.querySelector('.ql-video').src).toContain(
'http://player.vimeo.com/video/47762693/',
);
});

it('converts www.vimeo video url to embedded', function() {
insertVideo(this.tooltip, 'http://www.vimeo.com/47762693');
expect(this.container.querySelector('.ql-video').src).toContain('http://player.vimeo.com/video/47762693/');
expect(this.container.querySelector('.ql-video').src).toContain(
'http://player.vimeo.com/video/47762693/',
);
});

it('preserves vimeo video url protocol', function() {
insertVideo(this.tooltip, 'https://www.vimeo.com/47762693');
expect(this.container.querySelector('.ql-video').src).toContain('https://player.vimeo.com/video/47762693/');
expect(this.container.querySelector('.ql-video').src).toContain(
'https://player.vimeo.com/video/47762693/',
);
});

it('uses https as default vimeo video url protocol', function() {
insertVideo(this.tooltip, 'vimeo.com/47762693');
expect(this.container.querySelector('.ql-video').src).toContain('https://player.vimeo.com/video/47762693/');
expect(this.container.querySelector('.ql-video').src).toContain(
'https://player.vimeo.com/video/47762693/',
);
});

function insertVideo(tooltip, url) {
Expand Down

0 comments on commit 9908711

Please sign in to comment.