Skip to content

Commit aff757c

Browse files
committed
chore: add test to validate the CSP nonce is used to render the style
1 parent bd4b3a2 commit aff757c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/getScrollBarSize.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,27 @@ describe('getScrollBarSize', () => {
4747
height: 0,
4848
});
4949
});
50+
51+
it('should pass csp nonce to updateCSS', () => {
52+
const updateCSSSpy = jest.spyOn(
53+
require('../src/Dom/dynamicCSS'),
54+
'updateCSS',
55+
);
56+
57+
const target = document.createElement('div');
58+
document.body.appendChild(target);
59+
60+
const nonce = 'test-nonce-123';
61+
getTargetScrollBarSize(target, { nonce });
62+
63+
expect(updateCSSSpy).toHaveBeenCalledWith(
64+
expect.any(String),
65+
expect.any(String),
66+
{ csp: { nonce } },
67+
);
68+
69+
updateCSSSpy.mockRestore();
70+
document.body.removeChild(target);
71+
});
5072
});
5173
});

0 commit comments

Comments
 (0)