Skip to content

Commit

Permalink
Mocha tests for Solid backend
Browse files Browse the repository at this point in the history
  • Loading branch information
yasharpm committed Sep 2, 2024
1 parent afdfcf9 commit f6a95f6
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions test/unit/solid.test.ts
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

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 2 spaces but found 4

Check failure on line 11 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 2 spaces but found 4

beforeEach(() => {

Check failure on line 13 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 2 spaces but found 4

Check failure on line 13 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 2 spaces but found 4
rs = new RemoteStorage();

Check failure on line 14 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 4 spaces but found 8

Check failure on line 14 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 4 spaces but found 8
solid = rs.solid;

Check failure on line 15 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 4 spaces but found 8

Check failure on line 15 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 4 spaces but found 8
});

Check failure on line 16 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 2 spaces but found 4

Check failure on line 16 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 2 spaces but found 4

afterEach(() => {

Check failure on line 18 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 2 spaces but found 4

Check failure on line 18 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 2 spaces but found 4
rs.stopSync();

Check failure on line 19 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 4 spaces but found 8

Check failure on line 19 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 4 spaces but found 8
rs.disconnect();

Check failure on line 20 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 4 spaces but found 8

Check failure on line 20 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 4 spaces but found 8
Solid._rs_cleanup(rs);

Check failure on line 21 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 4 spaces but found 8

Check failure on line 21 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 4 spaces but found 8
});

Check failure on line 22 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (18)

Expected indentation of 2 spaces but found 4

Check failure on line 22 in test/unit/solid.test.ts

View workflow job for this annotation

GitHub Actions / node.js (20)

Expected indentation of 2 spaces but found 4

describe("configuration", () => {
it("configure sets userAddress when given", () => {
solid.configure({
userAddress: 'john.doe@gmail.com'
});
expect(solid.userAddress).to.equal('john.doe@gmail.com');
});

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);
});
});
});

0 comments on commit f6a95f6

Please sign in to comment.