Skip to content

Commit c272ed6

Browse files
Fix up pad.test.ts and table.test.ts
1 parent 9ed9d1a commit c272ed6

3 files changed

Lines changed: 30 additions & 40 deletions

File tree

__mocks__/rdflib.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@ export function Namespace() {
8080
}
8181
export class UpdateManager {
8282
editable() {}
83+
update() {}
8384
}

test/unit/pad.test.ts

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,62 @@
1+
jest.mock('rdflib')
12
import * 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

109
describe('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
})
2517
describe('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
})
4332
describe('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
})
5544
describe('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
})
6857
describe('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
})
8372
describe('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
})

test/unit/table.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const renderTableViewPane = require('../../src/table')
1+
import { default as renderTableViewPane } from '../../src/table'
2+
import { dom } from '../helpers/dom'
23

34
describe('renderTableViewPane', () => {
45
it('exists', () => {
56
expect(renderTableViewPane).toBeInstanceOf(Function)
67
})
7-
/*
8-
it('runs', () => {
8+
it.skip('runs', () => {
99
const doc = null
1010
const options = { sourceDocument: null, tableClass: null, query: null }
11-
expect(renderTableViewPane(doc, options))
12-
}) */
11+
expect(renderTableViewPane(dom, options)).toEqual(undefined)
12+
})
1313
})

0 commit comments

Comments
 (0)