Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate returned text against DLx Text schema #25

Open
dwhieb opened this issue Aug 22, 2019 · 1 comment
Open

validate returned text against DLx Text schema #25

dwhieb opened this issue Aug 22, 2019 · 1 comment
Labels

Comments

@dwhieb
Copy link
Member

dwhieb commented Aug 22, 2019

This is currently blocked because the main build of the DLx spec isn't working, due to a broken link to the GeoJSON spec.

Waiting on digitallinguistics/data-format#330

@dwhieb dwhieb added the test label Aug 22, 2019
@dwhieb
Copy link
Member Author

dwhieb commented Aug 22, 2019

In .travis.yml:

before_script:
  - npm install @digitallinguistics/spec yamljs

In test.js:

const AJV          = require(`../node_modules/@digitallinguistics/spec/test/utilities/ajv.js`);
const path         = require(`path`);
const { readFile } = require(`fs`).promises;

describe(`tags2dlx`, function() {

  let ajv;
  let convert;
  let text;
  let validate;

  beforeAll(async function() {

    ajv      = await AJV(); // eslint-disable-line new-cap
    validate = data => ajv.validate(`Text`, data);

    ({ default: convert } = await import(`../src/index.js`));

    text = await readFile(path.join(__dirname, `./test.txt`), `utf8`);

  });

  it(`returns a valid DLx Text object`, function() {

    const output  = convert(text);
    const isValid = validate(output);

    if (!isValid) fail(JSON.stringify(ajv.errors, null, 2));

  });

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant