Code coverage report for multilang-extract-comments/spec/handlebars-spec.js

Statements: 100% (11 / 11)      Branches: 100% (0 / 0)      Functions: 100% (4 / 4)      Lines: 100% (11 / 11)      Ignored: none     

All files » multilang-extract-comments/spec/ » handlebars-spec.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                              1 1   1 1 1       1 1                 1 1                 1 1                    
/*!
 * multilang-extract-comments <https://github.com/nknapp/multilang-extract-comments>
 *
 * Copyright (c) 2015 Nils Knappmeier.
 * Released under the MIT license.
 */
 
/* global describe */
/* global it */
// /* global xdescribe */
// /* global xit */
/* global expect */
 
'use strict'
 
var extract = require('../')
var fs = require('fs')
 
describe('extract comments from Handlebars', function () {
  var str = fs.readFileSync(require.resolve('./fixtures/body.hbs'))
  var comments = extract(str, {
    filename: 'body.hbs'
  })
 
  it('a simple comment', function () {
    expect(comments['1']).toEqual({
      begin: 1,
      end: 3,
      codeStart: 4,
      content: 'A comment without indent.\n',
      code: '{{>some-partial}}'
    })
  })
 
  it('a comment with indent content. Indents should be removed such that the smallest indent is 0', function () {
    expect(comments['6']).toEqual({
      begin: 6,
      end: 10,
      codeStart: 11,
      content: 'A comment with indent ...\n\n    ... and an other larger indent\n',
      code: '{{#if definitions}}'
    })
  })
 
  it('a comment with indent content and delimiters', function () {
    expect(comments['13']).toEqual({
      begin: 13,
      end: 15,
      codeStart: 16,
      content: 'Wholly indented comment\n    ',
      code: '    {{>json-schema/definitions}}'
    }
    )
  })
})