Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export default {
async serve(ctx) {
if (ctx.path.endsWith('.spec.js')) {
return await transform(ctx);
} else if (ctx.path === '/test_api_sanitizeAttribute') {
// The test in /test/api/sanitizeAttribute makes network requests
// The returned value doesn't matter; this is just to avoid
// unnecessary logging output
return '';
}
},
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* The URLs used in test are handled by the `serve` method defined in `serve-integration.js`.
* What they serve doesn't matter, it's just to avoid a 404 warning logged to console
*/
import {
createElement,
// Spy is created in a mock file and injected with the import map plugin
Expand Down Expand Up @@ -49,7 +53,7 @@ scenarios.forEach(({ type, attrName, tagName, Ctor }) => {
document.body.appendChild(elm);

const use = elm.shadowRoot.querySelector('use');
expect(use.getAttribute(attrName)).toBe('/foo');
expect(use.getAttribute(attrName)).toBe('/test_api_sanitizeAttribute?foo');
});

it('receives the right parameters', () => {
Expand All @@ -60,18 +64,18 @@ scenarios.forEach(({ type, attrName, tagName, Ctor }) => {
'use',
'http://www.w3.org/2000/svg',
attrName,
'/foo'
'/test_api_sanitizeAttribute?foo'
);
});

it('replace the original attribute value with a string', () => {
sanitizeAttributeSpy.mockReturnValue('/bar');
sanitizeAttributeSpy.mockReturnValue('/test_api_sanitizeAttribute?bar');

const elm = createElement(tagName, { is: Ctor });
document.body.appendChild(elm);

const use = elm.shadowRoot.querySelector('use');
expect(use.getAttribute(attrName)).toBe('/bar');
expect(use.getAttribute(attrName)).toBe('/test_api_sanitizeAttribute?bar');
});

it('replace the original attribute value with undefined', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LightningElement } from 'lwc';

export default class extends LightningElement {
href = '/foo';
href = '/test_api_sanitizeAttribute?foo';
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg>
<use href="/foo"></use>
<use href="/test_api_sanitizeAttribute?foo"></use>
</svg>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LightningElement } from 'lwc';

export default class extends LightningElement {
href = '/foo';
href = '/test_api_sanitizeAttribute?foo';
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg>
<use xlink:href="/foo"></use>
<use xlink:href="/test_api_sanitizeAttribute?foo"></use>
</svg>
</template>