Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardise NodeProcessor.data.ts constant names #2483

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 51 additions & 38 deletions packages/core/test/unit/html/NodeProcessor.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@ export const PROCESS_PANEL_ATTRIBUTES_EXPECTED = `
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY = `
<panel header="# Lorem ipsum">
<div slot="header">
This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes.
</div>
Header attribute should be ignored and deleted while header slot is reserved.
</panel>
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<panel>
<template #header><div>
This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes.
</div></template>
Header attribute should be ignored and deleted while header slot is reserved.
</panel>
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "panel has a header slot, 'header' attribute has no effect.";

export const PROCESS_PANEL_HEADER_NO_OVERRIDE = `
<panel header="# Lorem ipsum" alt="**strong alt**">
<div slot="header">
This existing header slot should be preserved in favour over header attribute.
Expand All @@ -49,7 +29,7 @@ export const PROCESS_PANEL_HEADER_NO_OVERRIDE = `
</panel>
`;

export const PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED = `
export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<panel><template #_alt><p><strong>strong alt</strong></p>
</template>
<template #header><div>
Expand All @@ -61,6 +41,8 @@ export const PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED = `
</panel>
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "panel has a header slot, 'header' attribute has no effect.";

// Post Process

export const POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT = `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if I'm missing something here, but it doesn't look like this one has an alt slot for it to test for it being inserted under panel as stated in your earlier comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:O You are right - I think I got confused by the text in the constant. Will delete the other constant then

Expand Down Expand Up @@ -92,18 +74,38 @@ export const PROCESS_QUESTION_ATTRIBUTES_EXPECTED = `
</question>
`;

export const PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE = `
<question header="**header**" hint="**hint**" answer="**answer**">
export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY = `
<question header="**lorem ipsum**">
<template slot="header"></template>
<template slot="hint"></template>
<template slot="answer"></template>
</question>
`;

export const PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<question>
<template #header></template>
</question>
`;

export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY = `
<question hint="**lorem ipsum**">
<template slot="hint"></template>
</question>
`;

export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED = `
<question>
<template #hint></template>
</question>
`;

export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY = `
<question answer="**lorem ipsum**">
<template slot="answer"></template>
</question>
`;

export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED = `
<question>
<template #answer></template>
</question>
`;
Expand All @@ -119,13 +121,13 @@ export const PROCESS_QOPTION_ATTRIBUTES_EXPECTED = `
</q-option>
`;

export const PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE = `
export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY = `
<q-option reason="**lorem ipsum**">
<template slot="reason"></template>
</q-option>
`;

export const PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED = `
<q-option>
<template #reason></template>
</q-option>
Expand All @@ -142,13 +144,13 @@ export const PROCESS_QUIZ_ATTRIBUTES_EXPECTED = `
</quiz>
`;

export const PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE = `
export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY = `
<quiz intro="**lorem ipsum**">
<template slot="intro"></template>
</quiz>
`;

export const PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED = `
<quiz>
<template #intro></template>
</quiz>
Expand All @@ -171,24 +173,35 @@ export const PROCESS_POPOVER_ATTRIBUTES_EXPECTED = `
</popover>
`;

export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE = `
<popover content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel tellus elit."
header="_Lorem ipsum_">
export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY = `
<popover header="_Lorem ipsum_">
<div slot="header">Some header slot content that should not be overwritten</div>
<div slot="content">Some content slot that should not be overwritten</div>
Content and header attributes should not be inserted under panel as slots, but should be deleted.
Header attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;

export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<popover>
<template #header><div>Some header slot content that should not be overwritten</div></template>
<template #content><div>Some content slot that should not be overwritten</div></template>
Content and header attributes should not be inserted under panel as slots, but should be deleted.
Header attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;

export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG = "popover has a header slot, 'header' attribute has no effect.";

export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY = `
<popover content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel tellus elit.">
<div slot="content">Some content slot that should not be overwritten</div>
Content attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;

export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED = `
<popover>
<template #content><div>Some content slot that should not be overwritten</div></template>
Content attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;
export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG = "popover has a content slot, 'content' attribute has no effect.";

/*
Expand Down
25 changes: 14 additions & 11 deletions packages/core/test/unit/html/NodeProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,42 @@ test('processNode processes panel attributes and inserts into dom as slots corre
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_NO_OVERRIDE,
testData.PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
});

test('processNode processes question attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES,
testData.PROCESS_QUESTION_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED);
});

test('processNode processes q-option attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES,
testData.PROCESS_QOPTION_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY,
testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED);
});

test('processNode processes quiz attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_QUIZ_ATTRIBUTES,
testData.PROCESS_QUIZ_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED);
});

test('processNode processes popover attributes and inserts into dom as slots correctly', () => {
const warnSpy = jest.spyOn(logger, 'warn');
processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES,
testData.PROCESS_POPOVER_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG);
processAndVerifyTemplate(testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY,
testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG);
});

Expand Down
Loading