mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-05 03:50:29 +01:00
@@ -424,7 +424,7 @@ async function performFlatteningCrop(
|
||||
return newPdfDoc.save();
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
export function resetState() {
|
||||
if (cropperState.cropper) {
|
||||
cropperState.cropper.destroy();
|
||||
cropperState.cropper = null;
|
||||
@@ -447,4 +447,6 @@ function resetState() {
|
||||
|
||||
const cropBtn = document.getElementById('crop-button') as HTMLButtonElement;
|
||||
if (cropBtn) cropBtn.disabled = true;
|
||||
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { resetState } from '../js/logic/crop-pdf-page.ts';
|
||||
|
||||
// Test resetState function for cropping
|
||||
describe('resetState', () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
it('scrolls the page to the top after resetting', () => {
|
||||
resetState();
|
||||
|
||||
expect(window.scrollTo).toHaveBeenCalledWith({
|
||||
top: 0,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user