feat: add darkMode and hideSelectors to Node.js and Python SDKs
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
This commit is contained in:
parent
96d21aa63b
commit
90c1e7da44
3 changed files with 125 additions and 0 deletions
|
|
@ -130,6 +130,98 @@ describe('SnapAPI', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('sends darkMode parameter correctly', async () => {
|
||||
const mockArrayBuffer = new ArrayBuffer(100);
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
arrayBuffer: () => Promise.resolve(mockArrayBuffer),
|
||||
});
|
||||
|
||||
await snap.capture('https://example.com', {
|
||||
darkMode: true,
|
||||
});
|
||||
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://snapapi.eu/v1/screenshot',
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
url: 'https://example.com',
|
||||
darkMode: true,
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('sends hideSelectors as string correctly', async () => {
|
||||
const mockArrayBuffer = new ArrayBuffer(100);
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
arrayBuffer: () => Promise.resolve(mockArrayBuffer),
|
||||
});
|
||||
|
||||
await snap.capture('https://example.com', {
|
||||
hideSelectors: '.ads',
|
||||
});
|
||||
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://snapapi.eu/v1/screenshot',
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
url: 'https://example.com',
|
||||
hideSelectors: '.ads',
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('sends hideSelectors as array correctly', async () => {
|
||||
const mockArrayBuffer = new ArrayBuffer(100);
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
arrayBuffer: () => Promise.resolve(mockArrayBuffer),
|
||||
});
|
||||
|
||||
await snap.capture('https://example.com', {
|
||||
hideSelectors: ['.ads', '.popup', '.banner'],
|
||||
});
|
||||
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://snapapi.eu/v1/screenshot',
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
url: 'https://example.com',
|
||||
hideSelectors: ['.ads', '.popup', '.banner'],
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('sends both darkMode and hideSelectors together', async () => {
|
||||
const mockArrayBuffer = new ArrayBuffer(100);
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
arrayBuffer: () => Promise.resolve(mockArrayBuffer),
|
||||
});
|
||||
|
||||
await snap.capture('https://example.com', {
|
||||
darkMode: true,
|
||||
hideSelectors: ['.ads', '.tracking'],
|
||||
format: 'png',
|
||||
});
|
||||
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://snapapi.eu/v1/screenshot',
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
url: 'https://example.com',
|
||||
darkMode: true,
|
||||
hideSelectors: ['.ads', '.tracking'],
|
||||
format: 'png',
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('works with ScreenshotOptions object form', async () => {
|
||||
const mockArrayBuffer = new ArrayBuffer(100);
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue