|
1 | 1 | jest.mock('rdflib') |
2 | | -// import * as RdfLib from 'rdflib' |
| 2 | +import * as RdfLib from 'rdflib' |
3 | 3 | jest.mock('solid-auth-client') |
4 | | -// import * as SolidAuthClient from 'solid-auth-client' |
5 | | -// import { DataBrowserContext } from 'pane-registry' |
6 | | -const AccessController = require('../../../src/acl/access-controller') |
7 | | -// just a note that the only public functions are isEditable, render, and save |
| 4 | +import * as SolidAuthClient from 'solid-auth-client' |
| 5 | +import { element, dom } from '../../helpers/dom' |
| 6 | + |
| 7 | +import { AccessController } from '../../../src/acl/access-controller' |
| 8 | +import { DataBrowserContext } from 'pane-registry' |
| 9 | + |
| 10 | +function instantiateAccessController() { |
| 11 | + const subject = RdfLib.sym('') |
| 12 | + const noun = '' |
| 13 | + const context = {} as DataBrowserContext |
| 14 | + const statusElement = element as unknown as HTMLElement |
| 15 | + const classes = {} |
| 16 | + const targetIsProtected = false |
| 17 | + const targetDoc = RdfLib.sym('') |
| 18 | + const targetACLDoc = RdfLib.sym('') |
| 19 | + const defaultHolder = RdfLib.sym('') |
| 20 | + const defaultACLDoc = RdfLib.sym('') |
| 21 | + const prospectiveDefaultHolder = RdfLib.sym('') |
| 22 | + const store = {} |
| 23 | + return new AccessController( |
| 24 | + subject, |
| 25 | + noun, |
| 26 | + context, |
| 27 | + statusElement, |
| 28 | + classes, |
| 29 | + targetIsProtected, |
| 30 | + targetDoc, |
| 31 | + targetACLDoc, |
| 32 | + defaultHolder, |
| 33 | + defaultACLDoc, |
| 34 | + prospectiveDefaultHolder, |
| 35 | + store, |
| 36 | + dom |
| 37 | + ) |
| 38 | +} |
8 | 39 | describe('AccessController', () => { |
9 | | - debugger |
10 | 40 | it('exists', () => { |
11 | 41 | expect(AccessController).toBeTruthy() |
12 | 42 | }) |
13 | | - /* leaving this for now |
14 | | - const subject = new RdfLib.NamedNode('testing') |
15 | | - const noun = 'noun' |
16 | | - const context = new DataBrowserContext() |
17 | | - const statusElement = HTMLElement |
18 | | - const classes = new Record<'test','test'> |
19 | | - const targetIsProtected= false |
20 | | - const targetDoc = new RdfLib.NamedNode('testing') |
21 | | - const targetACLDoc = new RdfLib.NamedNode('testing') |
22 | | - const defaultHolder = null |
23 | | - const defaultACLDoc = null |
24 | | - const prospectiveDefaultHolder = undefined |
25 | | - const store |
26 | | - const dom |
27 | | - const controller = new AccessController(subject, noun, context, statusElement, classes, targetIsProtected, targetDoc, targetACLDoc, defaultHolder, defaultACLDoc, prospectiveDefaultHolder, store, dom); |
| 43 | + it('runs', () => { |
| 44 | + expect(instantiateAccessController()).toBeInstanceOf(AccessController) |
| 45 | + }) |
| 46 | +}) |
| 47 | + |
| 48 | +describe('AccessController#isEditable', () => { |
| 49 | + it('exists', () => { |
| 50 | + expect(instantiateAccessController().isEditable).toEqual(false) |
| 51 | + }) |
| 52 | +}) |
| 53 | + |
| 54 | +describe('AccessController#render', () => { |
28 | 55 | it('exists', () => { |
29 | | - expect(controller.isEditable()). |
30 | | - }) */ |
| 56 | + expect(instantiateAccessController().render).toBeInstanceOf(Function) |
| 57 | + }) |
| 58 | + it('runs', () => { |
| 59 | + expect(instantiateAccessController().render()).toEqual(element) |
| 60 | + }) |
| 61 | +}) |
| 62 | + |
| 63 | +describe('AccessController#renderTemporaryStatus', () => { |
| 64 | + it('exists', () => { |
| 65 | + expect(instantiateAccessController().renderTemporaryStatus).toBeInstanceOf(Function) |
| 66 | + }) |
| 67 | + it('runs', () => { |
| 68 | + expect(instantiateAccessController().renderTemporaryStatus('')).toEqual(undefined) |
| 69 | + }) |
| 70 | +}) |
| 71 | + |
| 72 | + |
| 73 | +describe('AccessController#renderStatus', () => { |
| 74 | + it('exists', () => { |
| 75 | + expect(instantiateAccessController().renderStatus).toBeInstanceOf(Function) |
| 76 | + }) |
| 77 | + it('runs', () => { |
| 78 | + expect(instantiateAccessController().renderStatus('')).toEqual(undefined) |
| 79 | + }) |
| 80 | +}) |
| 81 | + |
| 82 | + |
| 83 | +describe('AccessController#save', () => { |
| 84 | + it('exists', () => { |
| 85 | + expect(instantiateAccessController().save).toBeInstanceOf(Function) |
| 86 | + }) |
| 87 | + it('runs', async () => { |
| 88 | + expect(instantiateAccessController().save()).resolves.toEqual(undefined) |
| 89 | + }) |
31 | 90 | }) |
| 91 | + |
0 commit comments