Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong committed Apr 4, 2024
1 parent 6ab15e4 commit f1df511
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export class HyperlinkPlugin implements EditorPlugin {
this.disposer();
this.disposer = null;
}

this.currentNode = null;
this.currentLink = null;
this.editor = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ describe('HyperlinkPlugin', () => {
expect(getAttributeSpy).toHaveBeenCalledWith('href');
expect(tooltipSpy).toHaveBeenCalledWith(mockedUrl, mockedLink);
expect(setDomAttributeSpy).toHaveBeenCalledWith('title', MockedTooltip);

plugin.dispose();
});

it('MouseOut', () => {
Expand Down Expand Up @@ -132,6 +134,8 @@ describe('HyperlinkPlugin', () => {
expect(getAttributeSpy).toHaveBeenCalledWith('href');
expect(tooltipSpy).not.toHaveBeenCalled();
expect(setDomAttributeSpy).toHaveBeenCalledWith('title', null);

plugin.dispose();
});

it('mouseUp', () => {
Expand Down Expand Up @@ -195,6 +199,8 @@ describe('HyperlinkPlugin', () => {

expect(preventDefaultSpy).toHaveBeenCalled();
expect(openSpy).toHaveBeenCalledWith(mockedUrl, '_blank');

plugin.dispose();
});

it('mouseUp with target', () => {
Expand Down Expand Up @@ -224,6 +230,8 @@ describe('HyperlinkPlugin', () => {

expect(preventDefaultSpy).toHaveBeenCalled();
expect(openSpy).toHaveBeenCalledWith(mockedUrl, mockedTarget);

plugin.dispose();
});

it('mouseUp with onLinkClick parameter', () => {
Expand Down Expand Up @@ -279,6 +287,8 @@ describe('HyperlinkPlugin', () => {
});
expect(preventDefaultSpy).toHaveBeenCalled();
expect(openSpy).toHaveBeenCalledWith(mockedUrl, '_blank');

plugin.dispose();
});

it('keyDown and keyUp', () => {
Expand Down Expand Up @@ -337,6 +347,8 @@ describe('HyperlinkPlugin', () => {

expect(containsSpy).toHaveBeenCalledWith(mockedNode);
expect(setAttributeSpy).toHaveBeenCalledWith('href', mockedUrl2);

plugin.dispose();
});

it('keyDown and keyUp, not contain', () => {
Expand Down Expand Up @@ -389,6 +401,8 @@ describe('HyperlinkPlugin', () => {

expect(containsSpy).toHaveBeenCalledWith(mockedNode);
expect(setAttributeSpy).not.toHaveBeenCalled();

plugin.dispose();
});

it('keyDown and keyUp, url not match', () => {
Expand Down Expand Up @@ -438,5 +452,7 @@ describe('HyperlinkPlugin', () => {

expect(containsSpy).not.toHaveBeenCalled();
expect(setAttributeSpy).not.toHaveBeenCalled();

plugin.dispose();
});
});

0 comments on commit f1df511

Please sign in to comment.