diff --git a/src/__tests__/utils.test.ts b/src/__tests__/utils.test.ts
index 30c12ce..b735904 100644
--- a/src/__tests__/utils.test.ts
+++ b/src/__tests__/utils.test.ts
@@ -2,6 +2,7 @@ import { version } from '../../package.json';
import {
Deferred,
genAppInstanceIdByName,
+ getContainerXPath,
getDefaultTplWrapper,
getWrapperId,
getXPathForElement,
@@ -101,6 +102,40 @@ it('Deferred should worked [2]', async () => {
expect(err).toBeInstanceOf(Error);
});
+it('should getContainerXPath work well', () => {
+ const article = document.createElement('article');
+ article.innerHTML = `
+
+ `;
+
+ document.body.appendChild(article);
+ // const testNode = document.querySelector('#testNode');
+ const xpath = getContainerXPath('#testNode');
+ expect(xpath).toEqual(
+ // eslint-disable-next-line max-len
+ `/*[name()='HTML']/*[name()='BODY'][1]/*[name()='ARTICLE'][1]/*[name()='DIV'][1]/*[name()='DIV'][2]`,
+ );
+ const testNode2 = document.createElement('div');
+ testNode2.innerHTML = `
+
+ `;
+
+ document.body.appendChild(testNode2);
+ const xpath1 = getContainerXPath(testNode2);
+
+ expect(xpath1).toEqual(
+ // eslint-disable-next-line max-len
+ `/*[name()='HTML']/*[name()='BODY'][1]/*[name()='DIV'][1]`,
+ );
+
+ const xpath2 = getContainerXPath(undefined);
+ expect(xpath2).toBeUndefined();
+});
+
it('should getXPathForElement work well', () => {
const article = document.createElement('article');
article.innerHTML = `