file_tree_test.coffee View source
require "test/env"

files = [
  'test/fixture/README.md',
  'test/fixture/parser.js',
  'test/fixture/actor.js'
]

Vows
  .describe('Lidoc parser')
  .addBatch
    'tree':
      topic: ->
        Lidoc.parse files: files, quiet: true, (project) =>
          @callback null, project.fileTree

      'should be the right type': (tree) ->
        assert.equal tree.constructor, Lidoc.FileNode

      'paths':
        './': (tree) ->
          assert.equal tree.name, ''

        './test/': (tree) ->
          assert.equal tree.paths['test'].name, 'test'

        './test/fixture/': (tree) ->
          assert.equal tree.paths['test'].paths['fixture'].name, 'fixture'

        './test/fixture/parser.html': (tree) ->
          node = tree.paths['test'].paths['fixture'].paths['parser.html']
          assert.equal node.fileID, 'test/fixture/parser.js'

      'ensure sorted': (tree) ->
        folder = tree.paths['test'].paths['fixture']

        names = []
        for name, file of folder.paths
          names.push name

        assert.equal names.join(","), ["actor.html","parser.html"]

  .export(module)