html2canvas-pro
Version:
Screenshots with JavaScript. Next generation!
61 lines • 4.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const globals_1 = require("@jest/globals");
const image_rendering_1 = require("../image-rendering");
const context_1 = require("../../../core/context");
const config_1 = require("../../../config");
(0, globals_1.describe)('property-descriptors', () => {
let context;
(0, globals_1.beforeEach)(() => {
const mockWindow = {
location: { href: 'http://example.com' },
document: { createElement: () => ({ href: '' }) }
};
const config = new config_1.Html2CanvasConfig({ window: mockWindow });
context = new context_1.Context({}, {}, config);
});
(0, globals_1.describe)('image-rendering', () => {
(0, globals_1.it)('should parse "auto" as AUTO', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'auto')).toBe(image_rendering_1.IMAGE_RENDERING.AUTO);
});
(0, globals_1.it)('should parse "pixelated" as PIXELATED', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'pixelated')).toBe(image_rendering_1.IMAGE_RENDERING.PIXELATED);
});
(0, globals_1.it)('should parse "crisp-edges" as CRISP_EDGES', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'crisp-edges')).toBe(image_rendering_1.IMAGE_RENDERING.CRISP_EDGES);
});
(0, globals_1.it)('should parse "-webkit-crisp-edges" as CRISP_EDGES', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, '-webkit-crisp-edges')).toBe(image_rendering_1.IMAGE_RENDERING.CRISP_EDGES);
});
(0, globals_1.it)('should parse "-webkit-optimize-contrast" as PIXELATED', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, '-webkit-optimize-contrast')).toBe(image_rendering_1.IMAGE_RENDERING.PIXELATED);
});
(0, globals_1.it)('should parse "smooth" as SMOOTH', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'smooth')).toBe(image_rendering_1.IMAGE_RENDERING.SMOOTH);
});
(0, globals_1.it)('should parse unknown values as AUTO', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'invalid')).toBe(image_rendering_1.IMAGE_RENDERING.AUTO);
});
(0, globals_1.it)('should be case-insensitive', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'PIXELATED')).toBe(image_rendering_1.IMAGE_RENDERING.PIXELATED);
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'Crisp-Edges')).toBe(image_rendering_1.IMAGE_RENDERING.CRISP_EDGES);
});
// Edge case tests
(0, globals_1.it)('should handle empty string as AUTO', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, '')).toBe(image_rendering_1.IMAGE_RENDERING.AUTO);
});
(0, globals_1.it)('should handle whitespace as AUTO', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, ' ')).toBe(image_rendering_1.IMAGE_RENDERING.AUTO);
});
(0, globals_1.it)('should handle special characters as AUTO', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, '@#$%')).toBe(image_rendering_1.IMAGE_RENDERING.AUTO);
});
(0, globals_1.it)('should parse "-moz-crisp-edges" as CRISP_EDGES', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, '-moz-crisp-edges')).toBe(image_rendering_1.IMAGE_RENDERING.CRISP_EDGES);
});
(0, globals_1.it)('should parse "high-quality" as SMOOTH', () => {
(0, globals_1.expect)(image_rendering_1.imageRendering.parse(context, 'high-quality')).toBe(image_rendering_1.IMAGE_RENDERING.SMOOTH);
});
});
});
//# sourceMappingURL=image-rendering.test.js.map