Skip to content

Commit 244e73c

Browse files
committed
Update tests.
1 parent 0eab434 commit 244e73c

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export function setCSPTrustedTypesPolicy(policy: CSPTrustedTypesPolicy | Promise
2525
cspTrustedTypesPolicyPromise = policy === null ? policy : Promise.resolve(policy)
2626
}
2727

28-
// TODO: find another way to make this available for testing.
29-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
30-
;(globalThis as any).setCSPTrustedTypesPolicy = setCSPTrustedTypesPolicy
31-
3228
export default class IncludeFragmentElement extends HTMLElement {
3329
static get observedAttributes(): string[] {
3430
return ['src', 'loading']

test/test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {assert} from '@open-wc/testing'
2-
import '../src/index.ts'
2+
import {setCSPTrustedTypesPolicy} from '../src/index.ts'
33

44
let count
55
const responses = {
@@ -648,13 +648,11 @@ suite('include-fragment-element', function () {
648648

649649
suite('CSP trusted types', () => {
650650
teardown(() => {
651-
// eslint-disable-next-line no-undef
652651
setCSPTrustedTypesPolicy(null)
653652
})
654653

655654
test('can set a pass-through mock CSP trusted types policy', async function () {
656655
let policyCalled = false
657-
// eslint-disable-next-line no-undef
658656
setCSPTrustedTypesPolicy({
659657
createHTML: htmlText => {
660658
policyCalled = true
@@ -672,7 +670,6 @@ suite('include-fragment-element', function () {
672670

673671
test('can set and clear a mutating mock CSP trusted types policy', async function () {
674672
let policyCalled = false
675-
// eslint-disable-next-line no-undef
676673
setCSPTrustedTypesPolicy({
677674
createHTML: () => {
678675
policyCalled = true
@@ -686,7 +683,6 @@ suite('include-fragment-element', function () {
686683
assert.equal('<b>replacement</b>', data)
687684
assert.ok(policyCalled)
688685

689-
// eslint-disable-next-line no-undef
690686
setCSPTrustedTypesPolicy(null)
691687
const el2 = document.createElement('include-fragment')
692688
el2.src = '/hello'
@@ -703,7 +699,6 @@ suite('include-fragment-element', function () {
703699
return htmlText
704700
}
705701
})
706-
// eslint-disable-next-line no-undef
707702
setCSPTrustedTypesPolicy(policy)
708703

709704
const el = document.createElement('include-fragment')
@@ -714,7 +709,6 @@ suite('include-fragment-element', function () {
714709
})
715710

716711
test('can reject data using a mock CSP trusted types policy', async function () {
717-
// eslint-disable-next-line no-undef
718712
setCSPTrustedTypesPolicy({
719713
createHTML: () => {
720714
throw new Error('Rejected data!')
@@ -732,7 +726,6 @@ suite('include-fragment-element', function () {
732726
})
733727

734728
test('can access headers using a mock CSP trusted types policy', async function () {
735-
// eslint-disable-next-line no-undef
736729
setCSPTrustedTypesPolicy({
737730
createHTML: (htmlText, response) => {
738731
if (response.headers.get('X-Server-Sanitized') !== 'sanitized=true') {

0 commit comments

Comments
 (0)