We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70a15e0 commit 9bd9123Copy full SHA for 9bd9123
lesson4.js
@@ -0,0 +1,28 @@
1
+// import { Permissions } from '@/lib/permissions'
2
+let args = []
3
+
4
+// Replace the imported Persmissions with a custom mock implementation
5
+const Permissions = {
6
+ granted(...params) {
7
+ args.push([...params])
8
+ }
9
+}
10
11
+// Potential User class
12
+class User {}
13
14
+const user = new User()
15
16
+// Function that uses the Permissions dependency
17
+// and now uses the mocked implementation
18
+function isUserAdmin() {
19
+ return Permissions.granted(user, 'admin')
20
21
22
+const test = function () {
23
+ isUserAdmin()
24
+ return JSON.stringify(args[0]) === JSON.stringify([user, 'admin'])
25
26
27
+// Execute the test and print out the result
28
+console.log(test())
0 commit comments