tdesign-mobile-vue
Version:
tdesign-mobile-vue
64 lines (61 loc) • 2.67 kB
JavaScript
/**
* tdesign v1.15.1
* (c) 2026 TDesign Group
* @license MIT
*/
import { a as afterEach, v as vi, d as describe, i as it, g as globalExpect } from '../../../../_chunks/dep-e7846056.js';
import calcTextareaHeight from '../../../js/utils/calcTextareaHeight.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';
import '@babel/runtime/helpers/construct';
import '@babel/runtime/helpers/assertThisInitialized';
import '@babel/runtime/helpers/possibleConstructorReturn';
import '@babel/runtime/helpers/getPrototypeOf';
import '@babel/runtime/helpers/inherits';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/typeof';
import '@babel/runtime/helpers/defineProperty';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/regenerator';
import '@babel/runtime/helpers/wrapNativeSuper';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../../../../_chunks/dep-7e6d79c9.js';
import '@babel/runtime/helpers/get';
import 'lodash-es';
import '../../../js/utils/helper.js';
afterEach(function () {
vi.restoreAllMocks();
document.body.innerHTML = "";
});
describe("calcTextareaHeight", function () {
it("removes hidden textarea after height calculation", function () {
var textarea = document.createElement("textarea");
textarea.value = "textarea content";
document.body.appendChild(textarea);
var result = calcTextareaHeight(textarea);
globalExpect(result.height).toBeDefined();
globalExpect(document.body.querySelectorAll("textarea")).toHaveLength(1);
});
it("removes hidden textarea after reentrant height calculations", function () {
var firstTextarea = document.createElement("textarea");
firstTextarea.value = "first textarea content";
document.body.appendChild(firstTextarea);
var secondTextarea = document.createElement("textarea");
secondTextarea.value = "second textarea content";
document.body.appendChild(secondTextarea);
var isReentered = false;
vi.spyOn(HTMLTextAreaElement.prototype, "scrollHeight", "get").mockImplementation(function mockScrollHeight() {
if (!isReentered && !this.isConnected) return 0;
if (!isReentered && this !== firstTextarea && this !== secondTextarea) {
isReentered = true;
calcTextareaHeight(secondTextarea);
}
return 20;
});
var result = calcTextareaHeight(firstTextarea);
globalExpect(result.height).toBeDefined();
globalExpect(document.body.querySelectorAll("textarea")).toHaveLength(2);
});
});
//# sourceMappingURL=calcTextareaHeight.test.js.map