/*!
 * acorn-extract-comments <https://github.com/tunnckoCore/acorn-extract-comments>
 *
 * Copyright (c) 2015-2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
 * Released under the MIT license.
 */

/* jshint asi:true */

'use strict'

var fs = require('fs')
var test = require('assertit')
var acornExtractComments = require('./index')

test('should throw TypeError if not a string', function (done) {
  function fixture () {
    acornExtractComments(123456)
  }

  test.throws(fixture, TypeError)
  test.throws(fixture, /expect `input` to be a string/)
  done()
})

test('should get empty array if empty string given', function (done) {
  var comments = acornExtractComments('')
  test.deepEqual(comments, [])
  done()
})

test('should get empty array if not comments found', function (done) {
  var input = fs.readFileSync('./index.js', 'utf8')
  var comments = acornExtractComments.line(input)

  test.strictEqual(comments.length, 0)
  done()
})

test('should get all comments, including ignored', function (done) {
  var input = fs.readFileSync('./index.js', 'utf8')
  var comments = acornExtractComments(input)

  test.strictEqual(comments.length, 6)
  done()
})

test('should get all comments, but not including `ignored`', function (done) {
  var input = fs.readFileSync('./index.js', 'utf8')
  var comments = acornExtractComments(input, {preserve: true})

  test.strictEqual(comments.length, 5)
  done()
})

test('should get only block with `.block` method', function (done) {
  var input = fs.readFileSync('./index.js', 'utf8')
  var comments = acornExtractComments.block(input)

  test.strictEqual(comments.length, 6)
  done()
})

test('should get only line with `.line` method', function (done) {
  var input = fs.readFileSync('./index.js', 'utf8')

  var comments = acornExtractComments.line(input)
  test.strictEqual(comments.length, 0)
  done()
})

@@ -944,32 +944,82 @@
 ents.length, 0)%0A
+  test.strictEqual(Array.isArray(comments), true)%0A
   done()%0A%7D)%0A%0Ates
@@ -1509,16 +1509,25 @@
 y block 
+comments 
 with %60.b
@@ -1655,32 +1655,76 @@
 s.block(input)%0A%0A
+  test.strictEqual(comments.ast, undefined)%0A
   test.strictEqu
@@ -1786,16 +1786,25 @@
 ly line 
+comments 
 with %60.l

fix "duplication", codeclimate sucks