var tester = require('gitbook-tester'); var test = require('tape'); function expect(t, version, content, expected) { tester.builder() .withContent(content) .withLocalPlugin(__dirname) .withBookJson({ gitbook: version, plugins: ['prism', '-highlight'] }) .create() .then(function(result) { t.equal(result[0].content, expected, 'gitbook version ' + version); }) .done(); } test('highlight javascript code block', function (t) { t.plan(2); var content = '```js\nfunction() { return true };\n```'; var expected = '
function() { return true };\n
';
expect(t, '>=2.4.1', content, expected);
expect(t, '>=3.0.0', content, expected);
});
test('highlight csharp code using shortcut', function (t) {
t.plan(2);
var content = '```cs\nusing System; class Program {public static void Main(string[] args) {Console.WriteLine("Hello, world!"); } }\n```';
var expected = 'using System; class Program {public static void Main(string[] args) {Console.WriteLine("Hello, world!"); } }\n
';
expect(t, '>=2.4.1', content, expected);
expect(t, '>=3.0.0', content, expected);
});