-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import 'mocha'; | ||
import chai, { expect } from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import Solid from "../../src/solid"; | ||
import RemoteStorage from '../../src/remotestorage'; | ||
|
||
chai.use(chaiAsPromised); | ||
|
||
|
||
describe('Solid backend', () => { | ||
let rs, solid; | ||
Check failure on line 11 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
|
||
beforeEach(() => { | ||
Check failure on line 13 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
rs = new RemoteStorage(); | ||
Check failure on line 14 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
solid = rs.solid; | ||
Check failure on line 15 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
}); | ||
Check failure on line 16 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
|
||
afterEach(() => { | ||
Check failure on line 18 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
rs.stopSync(); | ||
Check failure on line 19 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
rs.disconnect(); | ||
Check failure on line 20 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
Solid._rs_cleanup(rs); | ||
Check failure on line 21 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
}); | ||
Check failure on line 22 in test/unit/solid.test.ts GitHub Actions / node.js (18)
|
||
|
||
describe("configuration", () => { | ||
it("configure sets userAddress when given", () => { | ||
solid.configure({ | ||
userAddress: '[email protected]' | ||
}); | ||
expect(solid.userAddress).to.equal('[email protected]'); | ||
}); | ||
|
||
it("configure sets authURL when given", () => { | ||
solid.configure({ | ||
href: 'https://solidcommunity.net' | ||
}); | ||
expect(solid.authURL).to.equal('https://solidcommunity.net'); | ||
}); | ||
|
||
it("configure sets sessionProperties when given", () => { | ||
solid.configure({ | ||
properties: { | ||
sessionProperties: { check: true } | ||
} | ||
}); | ||
expect(solid.sessionProperties).to.eql({ check: true }); | ||
}); | ||
|
||
it("configure sets podURL when given", () => { | ||
solid.configure({ | ||
properties: { | ||
podURL: 'https://example.solidcommunity.net/' | ||
} | ||
}); | ||
expect(solid.selectedPodURL).to.equal('https://example.solidcommunity.net/'); | ||
}); | ||
}); | ||
|
||
describe("connection setup", () => { | ||
it("setAuthURL will update auth URL", () => { | ||
solid.setAuthURL('https://solidcommunity.net'); | ||
expect(solid.authURL).to.equal('https://solidcommunity.net'); | ||
}); | ||
|
||
it("setPodURL will update the selected pod URL", () => { | ||
solid.setPodURL('https://example.solidcommunity.net/'); | ||
expect(solid.selectedPodURL).to.equal('https://example.solidcommunity.net/'); | ||
}); | ||
|
||
it("connect will emit error if the auth URL is not set", () => { | ||
const errorCheck = { hasError: false }; | ||
rs.on('error', function(error) { | ||
expect(error.message).to.equal('No authURL is configured.'); | ||
errorCheck.hasError = true; | ||
}); | ||
solid.connect(); | ||
expect(errorCheck.hasError).to.eql(true); | ||
}); | ||
}); | ||
}); |