Skip to content

Commit 988ee0f

Browse files
committed
Added a couple of tests
1 parent 34e403d commit 988ee0f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/unit/user-utils-test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,43 @@
11
const chai = require('chai')
22
const expect = chai.expect
33
const userUtils = require('../../lib/common/user-utils')
4+
const $rdf = require('rdflib')
45

56
describe('user-utils', () => {
7+
describe('getName', () => {
8+
let ldp
9+
const webId = 'http://test#me'
10+
const name = 'NAME'
11+
12+
beforeEach(() => {
13+
const store = $rdf.graph()
14+
store.add($rdf.sym(webId), $rdf.sym('http://www.w3.org/2006/vcard/ns#fn'), $rdf.lit(name))
15+
ldp = { fetchGraph: () => Promise.resolve(store) }
16+
})
17+
18+
it('should return name from graph', async () => {
19+
const returnedName = await userUtils.getName(webId, { ldp })
20+
expect(returnedName).to.equal(name)
21+
})
22+
})
23+
24+
describe('getWebId', () => {
25+
let ldp
26+
const webId = 'https://test.localhost:8443/profile/card#me'
27+
28+
beforeEach(() => {
29+
ldp = {
30+
readContainerMeta: () => Promise.resolve(`<${webId}> <http://www.w3.org/ns/solid/terms#account> </>.`),
31+
suffixMeta: '.meta'
32+
}
33+
})
34+
35+
it('should return webId from meta file', async () => {
36+
const returnedWebId = await userUtils.getWebId('foo', 'https://bar/', { ldp })
37+
expect(returnedWebId).to.equal(webId)
38+
})
39+
})
40+
641
describe('isValidUsername', () => {
742
it('should accect valid usernames', () => {
843
const usernames = [

0 commit comments

Comments
 (0)