mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-24 09:21:06 -04:00
Add test for changes to component HTML on start
The updateContent JS was changed in this commit so
the replacement of the original HTML (with GOVUK
modules data-attributes) was moved into the start
method rather than being a slightly odd side
effect of the render function diffing:
476ed1593c
This adds a test to make it more clear this
happens, as requested in this comment:
https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804689618
This commit is contained in:
@@ -94,7 +94,7 @@ describe('Update content', () => {
|
||||
</div>`;
|
||||
|
||||
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}" aria-live="polite">
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}">
|
||||
${HTMLString}
|
||||
</div>`;
|
||||
|
||||
@@ -105,6 +105,15 @@ describe('Update content', () => {
|
||||
|
||||
});
|
||||
|
||||
test("It should replace the original HTML with that of the partial, to match that returned from AJAX responses", () => {
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
expect(document.querySelector('.ajax-block-container').parentNode.hasAttribute('data-resource')).toBe(false);
|
||||
|
||||
});
|
||||
|
||||
test("It should make requests to the URL specified in the data-resource attribute", () => {
|
||||
|
||||
// start the module
|
||||
@@ -302,7 +311,7 @@ describe('Update content', () => {
|
||||
}
|
||||
]);
|
||||
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}" aria-live="polite">
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}">
|
||||
${HTMLString}
|
||||
</div>`;
|
||||
|
||||
@@ -336,7 +345,7 @@ describe('Update content', () => {
|
||||
}
|
||||
]);
|
||||
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}" aria-live="polite">
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}">
|
||||
${HTMLString}
|
||||
</div>`;
|
||||
|
||||
@@ -401,7 +410,7 @@ describe('Update content', () => {
|
||||
}
|
||||
]);
|
||||
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}" aria-live="polite">
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}">
|
||||
${HTMLString}
|
||||
</div>`;
|
||||
|
||||
@@ -447,7 +456,7 @@ describe('Update content', () => {
|
||||
}
|
||||
]);
|
||||
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}" aria-live="polite">
|
||||
initialHTMLString = `<div data-module="update-content" data-resource="${resourceURL}" data-key="${updateKey}">
|
||||
${HTMLString}
|
||||
</div>`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user