@@ -13,6 +13,7 @@ import {
1313 getChinookConnection ,
1414 WARN_SPEED_MS ,
1515 EXPECT_SPEED_MS ,
16+ SELF_SIGNED_CERTIFICATE ,
1617 clearTestingDatabasesAsync
1718} from './shared'
1819
@@ -49,33 +50,28 @@ describe('connection', () => {
4950 } )
5051
5152 it ( 'should connect with config object string' , done => {
52- const configObj = parseConnectionString ( CHINOOK_DATABASE_URL )
53+ const configObj = getChinookConfig ( )
5354 const conn = new SQLiteCloudConnection ( configObj )
5455 expect ( conn ) . toBeDefined ( )
5556
56- // already connected?
57- if ( conn . connected ) {
57+ conn . connect ( error => {
58+ expect ( error ) . toBeNull ( )
59+ expect ( conn . connected ) . toBe ( true )
60+
5861 chinook . sendCommands ( 'TEST STRING' , ( error , results ) => {
5962 conn . close ( )
6063 expect ( conn . connected ) . toBe ( false )
6164 done ( )
6265 } )
63- } else {
64- // not connected, so connect...
65- conn . connect ( error => {
66- expect ( error ) . toBeNull ( )
67- expect ( conn . connected ) . toBe ( true )
68-
69- chinook . sendCommands ( 'TEST STRING' , ( error , results ) => {
70- conn . close ( )
71- expect ( conn . connected ) . toBe ( false )
72- done ( )
73- } )
74- } )
75- }
66+ } )
7667 } )
7768
7869 it ( 'should connect with connection string' , done => {
70+ if ( CHINOOK_DATABASE_URL . indexOf ( 'localhost' ) > 0 ) {
71+ // skip this test when running locally since it requires a self-signed certificate
72+ done ( )
73+ }
74+
7975 const conn = new SQLiteCloudConnection ( CHINOOK_DATABASE_URL )
8076 expect ( conn ) . toBeDefined ( )
8177
0 commit comments