Skip to content

Commit 5cdc579

Browse files
committed
Add a new test for properties when loading modules
1 parent e6324f7 commit 5cdc579

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/modules/loader/__tests__/loader.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ describe('bundle loading', () => {
5353
const promise = loadModuleBundleAsync('unknown_module', context)
5454
return expect(promise).rejects.toBeInstanceOf(ModuleConnectionError)
5555
})
56+
57+
test('Loading a bundle preserves properties', async () => {
58+
const context = mockContext(Chapter.SOURCE_4, Variant.DEFAULT)
59+
60+
function foo() {
61+
return foo.name
62+
}
63+
foo.someprop = true
64+
65+
expect('someprop' in foo).toEqual(true)
66+
67+
moduleMocker.mockReturnValueOnce({
68+
foo,
69+
bar: () => 'bar'
70+
})
71+
72+
const mod = await loadModuleBundleAsync('one_module', context)
73+
expect(mod.foo()).toEqual('foo')
74+
expect('someprop' in mod.foo).toEqual(true)
75+
})
5676
})
5777

5878
describe('tab loading', () => {

0 commit comments

Comments
 (0)