UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

20 lines (19 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const createElement_spec_1 = require("../test-helpers/createElement.spec"); const getComputedStyleAsNumber_1 = require("./getComputedStyleAsNumber"); describe('getComputedStyleAsNumber', () => { it('should return the height of an element as a number', () => { const element = (0, createElement_spec_1.createElement)('div', { height: '100px' }); expect((0, getComputedStyleAsNumber_1.getComputedStyleAsNumber)(element, 'height')).toEqual(100); }); it('should return the width of an element as a number', () => { const element = (0, createElement_spec_1.createElement)('div', { width: '100px' }); expect((0, getComputedStyleAsNumber_1.getComputedStyleAsNumber)(element, 'width')).toEqual(100); }); it('should throw an error if the element does not have a computed height', () => { const element = (0, createElement_spec_1.createElement)('div', { width: '100px' }); // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call expect(() => getComputedStyleAsNumber_1.getComputedStyleAsNumber(element, 'sausage')).toThrowError('Element does not have a computed "sausage'); }); });