1 | (function () {
|
2 | "use strict";
|
3 |
|
4 | var Highlight = require("../lib/highlight.js")
|
5 | , assert = require('assert')
|
6 | , fs = require('fs')
|
7 | , reHasAnnotations = /\sclass="[\w-]+"/
|
8 | ;
|
9 |
|
10 | function runTest(err) {
|
11 |
|
12 | assert.ok(!err, err && err.message);
|
13 | assert.strictEqual(1, Highlight.loadedLanguages.length, 'more than one language is loaded: ' + Highlight.loadedLanguages);
|
14 | assert.strictEqual('javascript', Highlight.loadedLanguages[0], 'javascript is the language');
|
15 |
|
16 | fs.readFile('./example.js.html', 'utf8', function (err, text) {
|
17 | var annotated
|
18 | ;
|
19 |
|
20 | assert.ok(!err, 'threw error reading example.js.html');
|
21 | annotated = Highlight.highlight(text, ' ', true);
|
22 | assert.ok(annotated.match(reHasAnnotations));
|
23 |
|
24 | console.info('[PASS] source is annotated');
|
25 | });
|
26 | }
|
27 |
|
28 | Highlight.init(runTest, ['javascript']);
|
29 | }());
|