|
1 | 1 | const chai = require('chai') |
2 | 2 | const expect = chai.expect |
3 | 3 | const userUtils = require('../../lib/common/user-utils') |
| 4 | +const $rdf = require('rdflib') |
4 | 5 |
|
5 | 6 | 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 | + |
6 | 41 | describe('isValidUsername', () => { |
7 | 42 | it('should accect valid usernames', () => { |
8 | 43 | const usernames = [ |
|
0 commit comments