import { Given , Then } from "@cucumber/cucumber" ; import { TypeDB , TypeDBClient , TypeDBCredential , User } from "../../../../dist" ; import { client } from "../ConnectionStepsBase" ; import assert = require ( "assert" ) ; Given ( "users contains: {word}" , async ( username ) => { const users = await getClient ( ) . users . all ( ) ; users . map ( ( user ) => user . username ) . includes ( username ) ; } ) ; Then ( "users not contains: {word}" , async ( username ) => { const users = await getClient ( ) . users . all ( ) ; ! users . map ( ( user ) => user . username ) . includes ( username ) ; } ) ; Then ( "users create: {word}, {word}" , async ( username , password ) => { await getClient ( ) . users . create ( username , password ) ; } ) ; Then ( "user password: {word}, {word}" , async ( username , password ) => { const user = await getClient ( ) . users . get ( username ) ; await user . password ( password ) ; } ) ; Then ( "user connect: {word}, {word}" , async ( username , password ) => { const client = await TypeDB . clusterClient ( [ TypeDB . DEFAULT_ADDRESS ] , new TypeDBCredential ( username , password , process . env . ROOT_CA ) ) ; await client . databases . all ( ) ; } ) ; Then ( "user delete: {word}" , async ( username ) => { const user = await getClient ( ) . users . get ( username ) ; await user . delete ( ) ; } ) ; function getClient ( ) { assert ( client . isCluster ( ) ) ; return client as TypeDBClient . Cluster ; }