Skip to content

Commit

Permalink
test(compartment-mapper): add a test case for package exports support…
Browse files Browse the repository at this point in the history
… in policy attenuators
  • Loading branch information
naugtur committed Nov 2, 2023
1 parent f746e99 commit 1ab5685
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions packages/compartment-mapper/test/test-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const defaultExpectations = {
redPill: 'undefined',
purplePill: 'number',
},
nestedScopedBob: { scoped: 1 },
scopedBob: { scoped: 1 },
builtins: '{"a":1,"b":2,"default":{"a":1,"b":2}}',
builtins2: '{"c":3,"default":{"c":3}}',
Expand Down Expand Up @@ -306,6 +307,15 @@ const errorAttenuatorForAllGlobals = recursiveEdit((key, obj) => {
}
});

const nestedAttenuator = recursiveEdit((key, obj) => {
if (key === 'attenuate') {
obj[key] = 'myattenuator/attenuate'
}
if (key === 'resources') {
obj[key]['myattenuator/attenuate'] = obj[key].myattenuator
}
});

scaffold(
'policy - globals attenuator',
test,
Expand Down Expand Up @@ -403,3 +413,18 @@ scaffold(
},
},
);

scaffold(
'policy - nested export in attenuator',
test,
fixture,
combineAssertions(
makeResultAssertions(defaultExpectations),
assertNoPolicyBypassImport,
),
2, // expected number of assertions
{
addGlobals: globals,
policy: nestedAttenuator(policy),
},
);

0 comments on commit 1ab5685

Please sign in to comment.