Skip to content

Commit

Permalink
get tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecTroemel committed Jul 1, 2024
1 parent c8f50a3 commit 8e5ef09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/tiptap-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function selectOption(option) {
}
function renderPopup(virtualNode) {
if (!popup.value) {
if (!popup.value && virtualNode) {
const rect = virtualNode.getBoundingClientRect();
popup.value = tippy(document.body, {
content: renderedErrors.value,
Expand All @@ -423,7 +423,6 @@ function renderPopup(virtualNode) {
}
function destroyPopup() {
console.log(popup.value);
if (popup.value) {
popup.value.destroy();
popup.value = null;
Expand Down
9 changes: 3 additions & 6 deletions test/TiptapEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,15 @@ describe('tiptap-editor.vue', () => {
expect(blueUnderline.exists()).toBeFalsy;
});

it('should render a popup', async () => {
it('should render correct popup suggestions', async () => {
propsData.value = 'red';
const wrapper = await mount(TiptapEditor, { propsData });

await flushPromises();
await wrapper.find('.tiptap').trigger('click');

const errorList = wrapper.find('.error-list');
const expectedHtml =
'<div class="error-list" v-show="false"><b>did you mean...</b> <div class="error-list__item selected"> read </div> <div class="error-list__item">reed</div></div>';
const receivedHtml = errorList.html().replace(/(\r\n|\r|\n)/g, '');
console.log(errorList.attributes());
expect(receivedHtml).toEqual(expectedHtml);
expect(errorList.text()).toEqual('did you mean...readreed');
});

it('should display correct word count', async () => {
Expand Down

0 comments on commit 8e5ef09

Please sign in to comment.