Created
June 4, 2024 10:56
-
-
Save eoghanmurray/52d0730eb8d7a209e27f29de0ddde455 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 9f5431270c352577df3982cef54262f600dad133 | |
Merge: a128758a9 70dae8fba | |
Author: Eoghan Murray <[email protected]> | |
Date: Tue Jun 4 11:49:51 2024 +0100 | |
WIP on removing-global-document-references: a128758a9 Add a test to ensure that we don't regress to using `document` in place of the passed in `doc` | |
diff --cc packages/rrweb-snapshot/test/rebuild.test.ts | |
index 097ff0989,097ff0989..6e5155532 | |
--- a/packages/rrweb-snapshot/test/rebuild.test.ts | |
+++ b/packages/rrweb-snapshot/test/rebuild.test.ts | |
@@@ -8,6 -8,6 +8,7 @@@ import | |
buildNodeWithSN, | |
createCache, | |
} from '../src/rebuild'; | |
++import rebuild from '../src/rebuild'; | |
import { NodeType } from '../src/types'; | |
import { createMirror, Mirror } from '../src/utils'; | |
@@@ -204,3 -204,3 +205,78 @@@ ul li.specified c:hover img, ul li.spec | |
}); | |
}); | |
}); | |
++ | |
++ | |
++describe('jsdom rebuild', () => { | |
++ let cache: ReturnType<typeof createCache>; | |
++ let mirror: Mirror; | |
++ | |
++ beforeEach(() => { | |
++ mirror = createMirror(); | |
++ cache = createCache(); | |
++ }); | |
++ | |
++ it("doesn't rely on global browser objects", () => { | |
++ const builtDoc = rebuild({"childNodes": [ | |
++ { | |
++ "id": 7, | |
++ "name": "html", | |
++ "publicId": "", | |
++ "rootId": 6, | |
++ "systemId": "", | |
++ "type": 1, | |
++ }, | |
++ { | |
++ "attributes": {}, | |
++ "childNodes": [ | |
++ { | |
++ "attributes": {}, | |
++ "childNodes": [], | |
++ "id": 9, | |
++ "rootId": 6, | |
++ "tagName": "head", | |
++ "type": 2, | |
++ }, | |
++ { | |
++ "attributes": {}, | |
++ "childNodes": [ | |
++ { | |
++ "attributes": {}, | |
++ "childNodes": [ | |
++ { | |
++ "id": 12, | |
++ "rootId": 6, | |
++ "textContent": "Hello world", | |
++ "type": 3, | |
++ }, | |
++ ], | |
++ "id": 11, | |
++ "rootId": 6, | |
++ "tagName": "p", | |
++ "type": 2, | |
++ }, | |
++ ], | |
++ "id": 10, | |
++ "rootId": 6, | |
++ "tagName": "body", | |
++ "type": 2, | |
++ }, | |
++ ], | |
++ "id": 8, | |
++ "rootId": 6, | |
++ "tagName": "html", | |
++ "type": 2, | |
++ }, | |
++ ], | |
++ "id": 6, | |
++ "type": 0, | |
++ }, | |
++ { | |
++ doc: document, // jsdom document | |
++ cache, | |
++ mirror, | |
++ } | |
++ ); | |
++ expect(builtDoc.innerHTML.length).toBeGreaterThan(100); | |
++ }); | |
++}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment