test.js 921 B

123456789101112131415161718192021222324
  1. var tester = require('gitbook-tester');
  2. var test = require('tape');
  3. var pkg = require('./package.json');
  4. test('should highlight javascript code block', function (t) {
  5. t.plan(1);
  6. tester.builder()
  7. .withContent('```js\nfunction() { return true };\n```')
  8. .withLocalPlugin(__dirname)
  9. .withBookJson({
  10. gitbook: pkg.engines.gitbook,
  11. plugins: ['prism', '-highlight']
  12. })
  13. .create()
  14. .then(function(result) {
  15. var expected = '<pre class="language-"><code class="lang-js"><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>\n</code></pre>';
  16. t.equal(result[0].content, expected);
  17. })
  18. .done();
  19. });