Skip to content

Commit e8def36

Browse files
Gozalarvagg
authored andcommitted
chore: add test for structural copying (#206)
* chore: add test for structural copying * fix: remove generated import * fix: lint errors * fix: another attempt to make eslint happy * chore: and another attemp to make eslint happy
1 parent b4ba07d commit e8def36

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/test-cid.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,4 +704,14 @@ describe('CID', () => {
704704
assert.isFalse(Object.keys(cid).includes('asCID'))
705705
assert.equal(cid.asCID, cid)
706706
})
707+
708+
it('CID can be moved across JS realms', async () => {
709+
const cid = CID.parse('bafybeif2pall7dybz7vecqka3zo24irdwabwdi4wc55jznaq75q7eaavvu')
710+
const { port1: sender, port2: receiver } = new MessageChannel()
711+
sender.postMessage(cid)
712+
const cid2 = await new Promise((resolve) => {
713+
receiver.onmessage = (event) => { resolve(event.data) }
714+
})
715+
assert.equal(cid2.asCID, cid2)
716+
})
707717
})

0 commit comments

Comments
 (0)