Options
All
  • Public
  • Public/Protected
  • All
Menu

External module TestHelpers

Index

Functions

xGetSchemaMapTxn

  • xGetSchemaMapTxn(dgraphClient: DgraphClient): Promise<ISchemaMap>
  • xGetSchemaMapTxn is useful for verifying you schema is what you think it is. Will ignore system predicates only returning the predicates you have set!

    const schema = `
     name: string @index(fulltext) .
     age: int .
     percent: float .
     awesome: bool .
     friend: uid @reverse .
     date: dateTime .
     location: geo .
    `;
    await xSetSchemaAlt(schema, dgraphClient);
    const schemaMap = await xGetSchemaMapTxn(dgraphClient);
    // check our schema
    expect(schemaMap.name.getType()).toBe('string');
    expect(schemaMap.age.getType()).toBe('int');

    Parameters

    • dgraphClient: DgraphClient

    Returns Promise<ISchemaMap>

xSetupForTest

xSetupWithSchemaDataCommitTxn

    • Sets some defaults like using port 9081 when testing vs 9080 when developing
    • Creates the client
    • Drops the DB
    • Sets a schema
    • Sets some initial data
    const schema = `
    name: string @index(exact) .
    street: string @index(exact) .
    `;
    
    const sampleData = {
    uid: "_:user",
    name: "cameron",
    addresses: [
     {uid: "_:address1", street: "william", postcode: 2000},
     {uid: "_:address2", street: "george", postcode: 2001},
     {uid: "_:address3", street: "hay", postcode: 2444},
     {uid: "_:address4", street: "short", postcode: 2107}
     ]
    };
    
    const {result, dgraphClient} = await xSetupWithSchemaDataCommitTxn({schema, data: sampleData});

    Parameters

    Returns Promise<ISetupReturnValue>

Generated using TypeDoc