Skip to content

Commit a27a554

Browse files
committed
fixed tests and style
1 parent 2a56e90 commit a27a554

File tree

12 files changed

+44
-56
lines changed

12 files changed

+44
-56
lines changed

src/style.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,3 @@ export const style = { // styleModule
165165
style.setStyle = function setStyle (ele, styleName) {
166166
ele.style = style[styleName]
167167
}
168-
169-
module.exports = style // @@ No way to do this in ESM

src/widgets/forms/basic.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ export function basicField (
131131
let params = fieldParams[uri]
132132
if (params === undefined) params = { style: '' } // non-bottom field types can do this
133133
const paramStyle = params.style || ''
134+
const inputStyle = style.textInputStyle + paramStyle
134135
const field = dom.createElement('input')
135-
;(field as any).style = style.textInputStyle + paramStyle
136+
;(field as any).style = inputStyle
136137
rhs.appendChild(field)
137138
field.setAttribute('type', params.type ? params.type : 'text')
138139

@@ -156,7 +157,7 @@ export function basicField (
156157
/* istanbul ignore next */
157158
field.value = obj.value || obj.value || ''
158159
}
159-
field.setAttribute('style', style)
160+
field.setAttribute('style', inputStyle)
160161
if (!kb.updater) {
161162
throw new Error('kb has no updater')
162163
}
@@ -176,7 +177,7 @@ export function basicField (
176177
if (params.pattern) {
177178
field.setAttribute(
178179
'style',
179-
style +
180+
inputStyle +
180181
(field.value.match(params.pattern)
181182
? 'color: green;'
182183
: 'color: red;')
@@ -191,7 +192,7 @@ export function basicField (
191192
// i.e. lose focus with changed data
192193
if (params.pattern && !field.value.match(params.pattern)) return
193194
field.disabled = true // See if this stops getting two dates from fumbling e.g the chrome datepicker.
194-
field.setAttribute('style', style + 'color: gray;') // pending
195+
field.setAttribute('style', inputStyle + 'color: gray;') // pending
195196
const ds = kb.statementsMatching(subject, property as any) // remove any multiple values
196197
let result
197198
if (params.namedNode) {
@@ -255,7 +256,7 @@ export function basicField (
255256
// kb.updater.update(ds, is, function (uri, ok, body) {
256257
if (ok) {
257258
field.disabled = false
258-
field.setAttribute('style', style)
259+
field.setAttribute('style', inputStyle)
259260
} else {
260261
box.appendChild(errorMessageBlock(dom, body))
261262
}

test/unit/acl/acl.mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { sym } from 'rdflib'
2-
import * as ns from '../../../src/ns'
2+
import ns from '../../../src/ns'
33
import { getFileContent } from '../helpers/getFileContent'
44
import { resolve } from 'path'
55

test/unit/acl/styles.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { silenceDebugMessages } from '../helpers/debugger'
2-
import * as Style from '../../../src/style'
2+
import { style } from '../../../src/style'
33

44
silenceDebugMessages()
55

66
describe('Style', () => {
77
it('exists', () => {
8-
expect(typeof Style).toEqual('object')
8+
expect(typeof style).toEqual('object')
99
})
1010
})

test/unit/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ describe('Index', () => {
3232
'table',
3333
'tabs',
3434
'utils',
35-
'versionInfo',
3635
'widgets'
3736
])
3837
})

test/unit/ns.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { silenceDebugMessages } from './helpers/debugger'
2-
import { rdf } from '../../src/ns'
2+
import ns from '../../src/ns'
33

44
silenceDebugMessages()
55

66
describe('RDF Namespace', () => {
77
it('gives the right URI for rdf:type', () => {
8-
expect(rdf('type').uri).toEqual('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
8+
expect(ns.rdf('type').uri).toEqual('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
99
})
1010
})

test/unit/style.test.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,51 @@
11
import { silenceDebugMessages } from './helpers/debugger'
2-
import {
3-
buttonStyle,
4-
classIconStyle,
5-
formTextInput,
6-
iconStyle,
7-
messageBodyStyle,
8-
multilineTextInputStyle,
9-
pendingeditModifier,
10-
signInAndUpButtonStyle,
11-
textInputStyle
12-
} from '../../src/style'
2+
import { style } from '../../src/style'
133

144
silenceDebugMessages()
155

166
describe('textInputStyle', () => {
177
it('exists', () => {
18-
expect(typeof textInputStyle).toEqual('string')
8+
expect(typeof style.textInputStyle).toEqual('string')
199
})
2010
})
2111

2212
describe('buttonStyle', () => {
2313
it('exists', () => {
24-
expect(typeof buttonStyle).toEqual('string')
14+
expect(typeof style.buttonStyle).toEqual('string')
2515
})
2616
})
2717
describe('iconStyle', () => {
2818
it('exists', () => {
29-
expect(typeof iconStyle).toEqual('string')
19+
expect(typeof style.iconStyle).toEqual('string')
3020
})
3121
})
3222
describe('classIconStyle', () => {
3323
it('exists', () => {
34-
expect(typeof classIconStyle).toEqual('string')
24+
expect(typeof style.classIconStyle).toEqual('string')
3525
})
3626
})
3727
describe('messageBodyStyle', () => {
3828
it('exists', () => {
39-
expect(typeof messageBodyStyle).toEqual('string')
29+
expect(typeof style.messageBodyStyle).toEqual('string')
4030
})
4131
})
4232
describe('pendingeditModifier', () => {
4333
it('exists', () => {
44-
expect(typeof pendingeditModifier).toEqual('string')
34+
expect(typeof style.pendingeditModifier).toEqual('string')
4535
})
4636
})
4737
describe('signInButtonStyle', () => {
4838
it('exists', () => {
49-
expect(typeof signInAndUpButtonStyle).toEqual('string')
39+
expect(typeof style.signInAndUpButtonStyle).toEqual('string')
5040
})
5141
})
5242
describe('formTextInput', () => {
5343
it('exists', () => {
54-
expect(typeof formTextInput).toEqual('string')
44+
expect(typeof style.formTextInput).toEqual('string')
5545
})
5646
})
5747
describe('multilineTextInputStyle', () => {
5848
it('exists', () => {
59-
expect(typeof multilineTextInputStyle).toEqual('string')
49+
expect(typeof style.multilineTextInputStyle).toEqual('string')
6050
})
6151
})

test/unit/tabs.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { label } from '../../src/utils'
88
import { solidLogicSingleton } from 'solid-logic'
99

1010
// @ts-ignore
11-
import { meeting, rdfs } from '../../src/ns'
11+
import ns from '../../src/ns'
1212

1313
const store = solidLogicSingleton.store
1414

@@ -36,9 +36,9 @@ describe('tabWidget', () => {
3636

3737
describe('minimal setup of options', () => {
3838
beforeAll(() => {
39-
const predicate = meeting('toolList')
39+
const predicate = ns.meeting('toolList')
4040
store.add(subject, predicate, new Collection([item1, item2]), subject.doc())
41-
store.add(item1, rdfs('label'), lit('Item 1'), subject.doc())
41+
store.add(item1, ns.rdfs('label'), lit('Item 1'), subject.doc())
4242

4343
tabWidgetElement = tabs.tabWidget({
4444
dom,
@@ -155,7 +155,7 @@ describe('tabWidget', () => {
155155
afterAll(clearStore)
156156

157157
it('allows for tabs to be fetched from triples instead of a collection', () => {
158-
const predicate = meeting('toolList')
158+
const predicate = ns.meeting('toolList')
159159
store.add(subject, predicate, item1, subject.doc())
160160
store.add(subject, predicate, item2, subject.doc())
161161
store.add(subject, predicate, item3, subject.doc())
@@ -238,7 +238,7 @@ describe('tabWidget', () => {
238238
tabWidgetElement = tabs.tabWidget({
239239
renderMain,
240240
renderTab,
241-
selectedTab: item2.uri,
241+
selectedTab: item2,
242242
...minimalOptions
243243
})
244244
})

test/unit/widgets/buttons.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ import {
4444
} from '../../../src/widgets/buttons'
4545
import { graph, namedNode, NamedNode, sym } from 'rdflib'
4646
// @ts-ignore
47-
import { foaf, rdf, sioc, vcard } from '../../../src/ns'
47+
import ns from '../../../src/ns'
4848
// @ts-ignore
4949
import { icons } from '../../../src/iconBase'
5050
import { clearStore } from '../helpers/clearStore'
5151
import { domWithHead } from '../../helpers/dom-with-head'
5252
import { solidLogicSingleton } from 'solid-logic'
53-
import * as style from '../../../src/style'
53+
import { style } from '../../../src/style'
5454
const { iconBase } = icons
5555
const store = solidLogicSingleton.store
5656

@@ -229,7 +229,7 @@ describe('createNameDiv', () => {
229229
})
230230

231231
it('uses the name from the obj if no title is given', () => {
232-
createNameDiv(dom, element, null, obj)
232+
createNameDiv(dom, element, undefined, obj)
233233
expect(element.children[0].textContent).toEqual('name')
234234
})
235235
})
@@ -274,31 +274,31 @@ describe('findImage', () => {
274274
expect(findImage).toBeInstanceOf(Function)
275275
})
276276
it('handles foaf(Agent)', () =>
277-
expect(findImage(foaf('Agent'))).toEqual(iconBase + 'noun_98053.svg'))
277+
expect(findImage(ns.foaf('Agent'))).toEqual(iconBase + 'noun_98053.svg'))
278278
it('handles rdf(Resource)', () =>
279-
expect(findImage(rdf('Resource'))).toEqual(iconBase + 'noun_98053.svg'))
279+
expect(findImage(ns.rdf('Resource'))).toEqual(iconBase + 'noun_98053.svg'))
280280
it('handles sioc(avatar)', () => {
281-
store.add(subject, sioc('avatar'), imageObject, subject.doc())
281+
store.add(subject, ns.sioc('avatar'), imageObject, subject.doc())
282282
expect(findImage(subject)).toEqual(imageObject.uri)
283283
})
284284
it('handles sioc(avatar)', () => {
285-
store.add(subject, foaf('img'), imageObject, subject.doc())
285+
store.add(subject, ns.foaf('img'), imageObject, subject.doc())
286286
expect(findImage(subject)).toEqual(imageObject.uri)
287287
})
288288
it('handles vcard(logo)', () => {
289-
store.add(subject, vcard('logo'), imageObject, subject.doc())
289+
store.add(subject, ns.vcard('logo'), imageObject, subject.doc())
290290
expect(findImage(subject)).toEqual(imageObject.uri)
291291
})
292292
it('handles vcard(hasPhoto)', () => {
293-
store.add(subject, vcard('hasPhoto'), imageObject, subject.doc())
293+
store.add(subject, ns.vcard('hasPhoto'), imageObject, subject.doc())
294294
expect(findImage(subject)).toEqual(imageObject.uri)
295295
})
296296
it('handles vcard(photo)', () => {
297-
store.add(subject, vcard('photo'), imageObject, subject.doc())
297+
store.add(subject, ns.vcard('photo'), imageObject, subject.doc())
298298
expect(findImage(subject)).toEqual(imageObject.uri)
299299
})
300300
it('handles foaf(depiction)', () => {
301-
store.add(subject, foaf('depiction'), imageObject, subject.doc())
301+
store.add(subject, ns.foaf('depiction'), imageObject, subject.doc())
302302
expect(findImage(subject)).toEqual(imageObject.uri)
303303
})
304304
it('returns null when nothing is found', () => expect(findImage(subject)).toBeNull())

test/unit/widgets/forms/basic.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
basicField
77
} from '../../../../src/widgets/forms/basic'
88
import ns from '../../../../src/ns'
9-
import { textInputStyle } from '../../../../src/style'
9+
import { style } from '../../../../src/style'
1010
import { clearStore } from '../../helpers/clearStore'
1111
import { store } from 'solid-logic'
1212

@@ -647,8 +647,8 @@ describe('basicField', () => {
647647
doc,
648648
callbackFunction
649649
)
650-
const style = (result.childNodes[1].childNodes[0] as HTMLInputElement).getAttribute('style')
651-
expect(style).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;text-align: right;')
650+
const localStyle = (result.childNodes[1].childNodes[0] as HTMLInputElement).getAttribute('style')
651+
expect(localStyle).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;text-align: right;')
652652
})
653653

654654
it('Defaults to textInputStyle', () => {
@@ -671,8 +671,8 @@ describe('basicField', () => {
671671
doc,
672672
callbackFunction
673673
)
674-
const style = (result.childNodes[1].childNodes[0] as HTMLInputElement).getAttribute('style')
675-
expect(style).toEqual(textInputStyle)
674+
const inputStyle = (result.childNodes[1].childNodes[0] as HTMLInputElement).getAttribute('style')
675+
expect(inputStyle).toEqual(style.textInputStyle)
676676
})
677677

678678
it('Can read type from fieldParams', () => {

0 commit comments

Comments
 (0)