-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add more tests for stub database adapter and test utils
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/entity/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { anything, instance, mock } from 'ts-mockito'; | ||
|
||
import { EntityPrivacyPolicyEvaluationContext } from '../../../EntityPrivacyPolicy'; | ||
import { EntityQueryContext } from '../../../EntityQueryContext'; | ||
import ViewerContext from '../../../ViewerContext'; | ||
import AlwaysAllowPrivacyPolicyRule from '../../../rules/AlwaysAllowPrivacyPolicyRule'; | ||
import AlwaysDenyPrivacyPolicyRule from '../../../rules/AlwaysDenyPrivacyPolicyRule'; | ||
import { describePrivacyPolicyRuleWithAsyncTestCase } from '../PrivacyPolicyRuleTestUtils'; | ||
|
||
describe(describePrivacyPolicyRuleWithAsyncTestCase, () => { | ||
describe('default args do not execute', () => { | ||
describePrivacyPolicyRuleWithAsyncTestCase(new AlwaysAllowPrivacyPolicyRule(), { | ||
allowCases: new Map([ | ||
[ | ||
'case', | ||
async () => ({ | ||
viewerContext: instance(mock(ViewerContext)), | ||
queryContext: instance(mock(EntityQueryContext)), | ||
evaluationContext: instance(mock<EntityPrivacyPolicyEvaluationContext>()), | ||
entity: anything(), | ||
}), | ||
], | ||
]), | ||
}); | ||
|
||
describePrivacyPolicyRuleWithAsyncTestCase(new AlwaysDenyPrivacyPolicyRule(), { | ||
denyCases: new Map([ | ||
[ | ||
'case', | ||
async () => ({ | ||
viewerContext: instance(mock(ViewerContext)), | ||
queryContext: instance(mock(EntityQueryContext)), | ||
evaluationContext: instance(mock<EntityPrivacyPolicyEvaluationContext>()), | ||
entity: anything(), | ||
}), | ||
], | ||
]), | ||
}); | ||
}); | ||
}); |
This file contains 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