import "reflect-metadata" ; const rmock = require ( "mock-require" ) ; rmock ( "vscode" , { } ) ; import { assert } from "chai" ; import { Credentials } from "../../../src/bll/credentialsstore/credentials" ; import { InMemoryCredentialsStore } from "../../../src/bll/credentialsstore/inmemorycredentialsstore" ; suite ( "CredentialStore" , function ( ) { test ( "should verify constructor" , function ( ) { const cs = getImMemoryStorage ( ) ; assert . equal ( cs . getCredentialsSilently ( ) , undefined ) ; } ) ; test ( "should verify set/getCredential" , async function ( ) { const credentials = new Credentials ( "http://localhost:8239" , "user" , "password" , "1" , "xxx" ) ; const cs = getImMemoryStorage ( ) ; await cs . setCredentials ( credentials ) ; assert . equal ( cs . getCredentialsSilently ( ) , credentials ) ; } ) ; test ( "should verify set/getCredential - rewriting" , async function ( ) { const credentials = new Credentials ( "http://localhost:7239" , "user" , "password" , "1" , "xxx" ) ; const credentials2 = new Credentials ( "http://localhost:4239" , "user2" , "password2" , "2" , "yyy" ) ; const cs = getImMemoryStorage ( ) ; await cs . setCredentials ( credentials ) ; await cs . setCredentials ( credentials2 ) ; assert . equal ( cs . getCredentialsSilently ( ) , credentials2 ) ; } ) ; test ( "should verify removeCredential" , async function ( ) { const credentials = new Credentials ( "http://localhost" , "user" , "password" , "1" , "xxx" ) ; const cs = getImMemoryStorage ( ) ; await cs . setCredentials ( credentials ) ; await cs . removeCredentials ( ) ; assert . equal ( cs . getCredentialsSilently ( ) , undefined ) ; } ) ; } ) ; function getImMemoryStorage ( ) { return new InMemoryCredentialsStore ( undefined , undefined , undefined , undefined , undefined , undefined , undefined , undefined ) ; }