MCPcopy Create free account
hub / github.com/mailvelope/mailvelope / createMockElementWithOwnerDocument

Function createMockElementWithOwnerDocument

test/unit/__mocks__/mockDOM.js:80–101  ·  view source on GitHub ↗
(selection)

Source from the content-addressed store, hash-verified

78 * @returns {Object} Mock element with ownerDocument.getSelection
79 */
80export function createMockElementWithOwnerDocument(selection) {
81 const element = document.createElement('div');
82
83 Object.defineProperty(element, 'ownerDocument', {
84 value: {
85 getSelection: jest.fn(() => selection)
86 },
87 configurable: true
88 });
89
90 // Add parentElement that is not a pre element
91 Object.defineProperty(element, 'parentElement', {
92 value: {
93 tagName: {
94 toLowerCase: () => 'div'
95 }
96 },
97 configurable: true
98 });
99
100 return element;
101}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected