Code Monkey home page Code Monkey logo

ad4m-test's Introduction

AD4M Test

This is a testing library for testing languages for ad4m. This package internally uses ad4m-host v0.0.9 to start and interact with ad4m-executor. For more detailed example look go here

Usage

Install the package:

npm:

npm install ad4m-test

yarn:

yarn add ad4m-test

Write tests

You can write tests like you would with any other testing framework. You can use the helper methods to interact with the ad4m-executor.

example

const { createExpression, getExpression } = require('ad4m-test/helpers')

describe("Expression", () => {
  it("Create Expression", async () => {
    const exp = await createExpression("{\"name\": \"hello world!\"}");

    expect(exp).not.toBeNull()

    const fetched = await getExpression(exp);

    expect(fetched).not.toBeNull()
  })
})

Then your can run the test like so:

ad4m-test --test ./expression.test.js --bundle languages/sdp.js --meta '{\"name\":\"shortform-expression\",\"description\":\"Shortform expression for flux application\",\"sourceCodeLink\":\"https://github.com/juntofoundation/ad4m-languages\",\"possibleTemplateParams\":[\"uid\",\"name\"]}'

ExpressionUI testing

Running the below command will start a local server which will host the ExpressionUI which can be used to test UI for the expression language.

ad4m-test --ui --bundle languages/sdp.js --meta '{\"name\":\"shortform-expression\",\"description\":\"Shortform expression for flux application\",\"sourceCodeLink\":\"https://github.com/juntofoundation/ad4m-languages\",\"possibleTemplateParams\":[\"uid\",\"name\"]}'

API:

Cli params:

  • relativePath | rp - Relative path to the appdata for ad4m-host to store binaries
  • port | p - Use this port to run ad4m GraphQL service
  • test | t - Runs test on a single file
  • bundle | b - Language bundle for the language to be tested
  • meta | m - Meta information for the language to be installed
  • languageTye | lt - Is the language a link or expression language
  • defaultLangPath | dlp - Local bulid-in language to be used instead of the packaged ones
  • hideLogs | hl - Hide the ad4m-test logs
  • ui - Starts a local server with expressionUI loaded for testing.

Helpers:

  • addLink(link: LinkExpression) - Adds link and returns added link.
  • removeLink(link: LinkExpression) - Removes links.
  • udpateLink(oldLink: LinkExpression, newLink: LinkExpression) - Updates the old link and return a new one.
  • queryLinks(query: LinkQuery) - gets all the link for that perspective.
  • createExpression(content: any) - Creates an expression with the supplied content and returns expression url.
  • getExpression(url: string) - Fetches the expression from the url passed.

ad4m-test's People

Contributors

fayeed avatar jdeepee avatar lucksus avatar

Watchers

 avatar kaichao avatar

ad4m-test's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.