Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ Below is a list of available options, default value is emphasized.
There are two suites of tests for this repository. The first is `spec/htmlbook_spec.js` and tests the package for expected output. Run this test with the following:

```bash
$ jasmine-node spec/htmlbook_spec.js
$ npx jasmine spec/htmlbook_spec.js
```

The second test suite checks to be sure that the file being tested in `htmlbook_spec` are in fact being output to valid HTMLBook. It's no use writing tests that pass unless they pass on valid output. These tests are separated because the validation takes longer.

```bash
$ jasmine-node spec/validation_spec.js
```
$ npx jasmine spec/validation_spec.js
```
1 change: 0 additions & 1 deletion spec/htmlbook_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var htmlbook = require('../htmlbook');
var fs = require('fs');
var S = require('string');
var marked = require('marked');
marked.setOptions({gfm: true});

Expand Down
46 changes: 28 additions & 18 deletions spec/validation_spec.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
var htmlbook = require('../htmlbook');
var fs = require('fs');
var exec = require('child_process').exec;
const tmp = require('tmp');

jasmine.getEnv().defaultTimeoutInterval = 100000;
tmp.setGracefulCleanup();

jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;

var convert_and_validate = function (file_name, callback) {
fs.readFile(file_name, "utf-8", function (err, source) {
tmp.file((err, path, _) => {
if (err) throw err;
fs.readFile(file_name, "utf-8", function (err, source) {
if (err) throw err;

html = htmlbook(source).parse({"complete_html": true, "title": "Test"})
html = htmlbook(source).parse({ "complete_html": true, "title": "Test" })

fs.writeFile("spec/documents/validation.html", html, function () {
exec("xmllint --noout --schema ../HTMLBook/schema/htmlbook.xsd spec/documents/validation.html", function (err, stdout, stderr) {
expect(stderr).toEqual("spec/documents/validation.html validates\n");
fs.unlink("spec/documents/validation.html");
callback();
});
})
});
fs.writeFile(`${path}.html`, html, function () {
exec(`xmllint --noout --schema ../HTMLBook/schema/htmlbook.xsd ${path}.html`, function (err, _stdout, stderr) {
if (err) throw err;
expect(stderr).toEqual(`${path}.html validates\n`);
callback();
});
})
});

}

)
}

describe("htmlbook validations", function () {
it("BBEPart2", function (done) {
xit("BBEPart2", function (done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to keep these tests if they're no longer needed? Or figure out how to fix at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have disappeared from the repo; I'd like to try and find them eventually, but maybe it's not worth it? I could go either way; this is not a heavily used part of Atlas (and in fact we recommend against it, strongly).

convert_and_validate("spec/samples/BBEPart2.md", done)
})

it("streams", function (done) {
xit("streams", function (done) {
convert_and_validate("spec/samples/streams.md", done)
})

it("artofnode", function (done) {
xit("artofnode", function (done) {
convert_and_validate("spec/samples/artofnode.md", done)
})

it("dataviz tech", function (done) {
xit("dataviz tech", function (done) {
convert_and_validate("spec/samples/dataviz_tech.md", done)
})

it("dataviz data", function (done) {
xit("dataviz data", function (done) {
convert_and_validate("spec/samples/dataviz_data.md", done)
})

Expand All @@ -60,7 +70,7 @@ describe("htmlbook validations", function () {
convert_and_validate("spec/documents/math.md", done);
});

it ("should convert opengovernment spec", function (done) {
it("should convert opengovernment spec", function (done) {
convert_and_validate("../HTMLBook/samples/markdown/open_government_sample.md", done);
});
});
});