/
globalWrites.spec.js
48 lines (47 loc) · 1.13 KB
/
globalWrites.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-disable no-undef */
const test = require('ava')
const {
createScenarioFromScaffold,
runAndTestScenario,
} = require('lavamoat-core/test/util')
const { runScenario } = require('./util')
// here we are providing an endowments only to a module deep in a dep graph
test('globalWrites - two deps should be able to read each others globals', async (t) => {
const scenario = createScenarioFromScaffold({
name: 'globalWrites - two deps should be able to read each others globals',
defineOne: () => {
module.exports = require('two')
},
defineTwo: () => {
xyz = true
module.exports = require('three')
},
defineThree: () => {
module.exports = xyz
},
config: {
resources: {
$root$: {
packages: {
two: true,
},
},
two: {
globals: {
xyz: 'write',
},
packages: {
three: true,
},
},
three: {
globals: {
xyz: true,
},
},
},
},
expectedResult: true,
})
await runAndTestScenario(t, scenario, runScenario)
})