1
+ import 'mocha' ;
2
+ import chai , { expect } from 'chai' ;
3
+ import chaiAsPromised from 'chai-as-promised' ;
4
+ import Solid from "../../src/solid" ;
5
+ import RemoteStorage from '../../src/remotestorage' ;
6
+
7
+ chai . use ( chaiAsPromised ) ;
8
+
9
+
10
+ describe ( 'Solid backend' , ( ) => {
11
+ let rs , solid ;
12
+
13
+ beforeEach ( ( ) => {
14
+ rs = new RemoteStorage ( ) ;
15
+ solid = rs . solid ;
16
+ } ) ;
17
+
18
+ afterEach ( ( ) => {
19
+ rs . stopSync ( ) ;
20
+ rs . disconnect ( ) ;
21
+ Solid . _rs_cleanup ( rs ) ;
22
+ } ) ;
23
+
24
+ describe ( "configuration" , ( ) => {
25
+ it ( "configure sets userAddress when given" , ( ) => {
26
+ solid . configure ( {
27
+ userAddress : 'john.doe@gmail.com'
28
+ } ) ;
29
+ expect ( solid . userAddress ) . to . equal ( 'john.doe@gmail.com' ) ;
30
+ } ) ;
31
+
32
+ it ( "configure sets authURL when given" , ( ) => {
33
+ solid . configure ( {
34
+ href : 'https://solidcommunity.net'
35
+ } ) ;
36
+ expect ( solid . authURL ) . to . equal ( 'https://solidcommunity.net' ) ;
37
+ } ) ;
38
+
39
+ it ( "configure sets sessionProperties when given" , ( ) => {
40
+ solid . configure ( {
41
+ properties : {
42
+ sessionProperties : { check : true }
43
+ }
44
+ } ) ;
45
+ expect ( solid . sessionProperties ) . to . eql ( { check : true } ) ;
46
+ } ) ;
47
+
48
+ it ( "configure sets podURL when given" , ( ) => {
49
+ solid . configure ( {
50
+ properties : {
51
+ podURL : 'https://example.solidcommunity.net/'
52
+ }
53
+ } ) ;
54
+ expect ( solid . selectedPodURL ) . to . equal ( 'https://example.solidcommunity.net/' ) ;
55
+ } ) ;
56
+ } ) ;
57
+
58
+ describe ( "connection setup" , ( ) => {
59
+ it ( "setAuthURL will update auth URL" , ( ) => {
60
+ solid . setAuthURL ( 'https://solidcommunity.net' ) ;
61
+ expect ( solid . authURL ) . to . equal ( 'https://solidcommunity.net' ) ;
62
+ } ) ;
63
+
64
+ it ( "setPodURL will update the selected pod URL" , ( ) => {
65
+ solid . setPodURL ( 'https://example.solidcommunity.net/' ) ;
66
+ expect ( solid . selectedPodURL ) . to . equal ( 'https://example.solidcommunity.net/' ) ;
67
+ } ) ;
68
+
69
+ it ( "connect will emit error if the auth URL is not set" , ( ) => {
70
+ const errorCheck = { hasError : false } ;
71
+ rs . on ( 'error' , function ( error ) {
72
+ expect ( error . message ) . to . equal ( 'No authURL is configured.' ) ;
73
+ errorCheck . hasError = true ;
74
+ } ) ;
75
+ solid . connect ( ) ;
76
+ expect ( errorCheck . hasError ) . to . eql ( true ) ;
77
+ } ) ;
78
+ } ) ;
79
+ } ) ;
0 commit comments