1+ jest . mock ( 'rdflib' )
12import * as RdfLib from 'rdflib'
2- import { dom } from '../helpers/dom'
3- const pad = require ( '../../src/pad' )
4- import { currentSession } from '../../__mocks__/solid-auth-client '
3+ jest . mock ( 'solid-auth-client' )
4+ import * as SolidAuthClient from 'solid-auth-client'
5+ import { dom , element } from '../helpers/dom '
56
6- export async function getMyWebId ( ) : Promise < string | null > {
7- return currentSession ( )
8- }
7+ import * as pad from '../../src/pad'
98
109describe ( 'lightColorHash' , ( ) => {
1110 it ( 'exists' , ( ) => {
12- expect ( pad . lightColorHash ) . toBeInstanceOf ( Function )
11+ expect ( ( pad as any ) . lightColorHash ) . toBeInstanceOf ( Function )
1312 } )
1413 it ( 'runs' , ( ) => {
15- expect ( pad . lightColorHash ( null ) ) . toBe ( '#ffffff' )
14+ expect ( ( pad as any ) . lightColorHash ( null ) ) . toBe ( '#ffffff' )
1615 } )
17- /* TODO: gives a warning instead of an error... need to research
18- const author = new NamedNode('author')
19- console.log('Named node ' + JSON.stringify(author))
20- it('should return error that you need to be logged in for pad to be edited', () => {
21- expect(pad.lightColorHash(author)).toThrowError()
22- })
23- */
2416} )
2517describe ( 'renderPartipants' , ( ) => {
26- const webId = getMyWebId ( )
27-
2818 it ( 'exists' , ( ) => {
29- expect ( pad . renderPartipants ) . toBeInstanceOf ( Function )
19+ expect ( ( pad as any ) . renderPartipants ) . toBeInstanceOf ( Function )
3020 } )
31- // TODO: need to fix up the arguments
3221 it ( 'runs' , ( ) => {
3322 const table = dom . createElement ( )
3423 const padDoc = null
3524 const subject = RdfLib . sym ( '' )
36- const me = webId
25+ const me = ' webId'
3726 const options = { }
3827 expect (
39- pad . renderPartipants ( dom , table , padDoc , subject , me , options )
28+ ( pad as any ) . renderPartipants ( dom , table , padDoc , subject , me , options )
4029 ) . toBeTruthy ( )
4130 } )
4231} )
4332describe ( 'participationObject' , ( ) => {
4433 it ( 'exists' , ( ) => {
45- expect ( pad . participationObject ) . toBeInstanceOf ( Function )
34+ expect ( ( pad as any ) . participationObject ) . toBeInstanceOf ( Function )
4635 } )
4736 // TODO: check on arguments
4837 const subject = null
4938 const padDoc = null
5039 const me = null
5140 it ( 'runs' , ( ) => {
52- expect ( pad . participationObject ( subject , padDoc , me ) ) . resolves . toBe ( { } )
41+ expect ( ( pad as any ) . participationObject ( subject , padDoc , me ) ) . resolves . toBe ( { } )
5342 } )
5443} )
5544describe ( 'recordParticipation' , ( ) => {
5645 it ( 'exists' , ( ) => {
57- expect ( pad . recordParticipation ) . toBeInstanceOf ( Function )
46+ expect ( ( pad as any ) . recordParticipation ) . toBeInstanceOf ( Function )
5847 } )
5948 const subject = null
6049 const padDoc = null
6150 const refreshable = true
6251 it ( 'runs' , ( ) => {
63- expect ( pad . recordParticipation ( subject , padDoc , refreshable ) ) . toBe (
52+ expect ( ( pad as any ) . recordParticipation ( subject , padDoc , refreshable ) ) . toBe (
6453 undefined
6554 )
6655 } )
6756} )
6857describe ( 'manageParticipation' , ( ) => {
6958 it ( 'exists' , ( ) => {
70- expect ( pad . manageParticipation ) . toBeInstanceOf ( Function )
59+ expect ( ( pad as any ) . manageParticipation ) . toBeInstanceOf ( Function )
7160 } )
7261 const container = dom . createElement ( )
7362 const padDoc = null
@@ -76,20 +65,20 @@ describe('manageParticipation', () => {
7665 const options = { }
7766 it ( 'runs' , ( ) => {
7867 expect (
79- pad . manageParticipation ( dom , container , padDoc , subject , me , options )
68+ ( pad as any ) . manageParticipation ( dom , container , padDoc , subject , me , options )
8069 ) . toBeTruthy ( )
8170 } )
8271} )
8372describe ( 'notepad' , ( ) => {
8473 it ( 'exists' , ( ) => {
85- expect ( pad . notepad ) . toBeInstanceOf ( Function )
74+ expect ( ( pad as any ) . notepad ) . toBeInstanceOf ( Function )
8675 } )
87- /* TODO: says updater is not a function, need to look into this
88- const padDoc = null
89- const subject = null
90- const me = null
91- const options = {}
76+
9277 it ( 'runs' , ( ) => {
93- expect(pad.notepad(dom, padDoc, subject, me, options)).toBe(null)
94- }) */
78+ const padDoc = null
79+ const subject = null
80+ const me = null
81+ const options = { }
82+ expect ( ( pad as any ) . notepad ( dom , padDoc , subject , me , options ) ) . toBe ( element )
83+ } )
9584} )
0 commit comments