'use strict'

vows = require ('vows')
assert = require ('assert')
fishlint = require ('../../fishlint')

vows
	.describe('fishlint node module versioning')
	.addBatch
		'Get version as a':
			'short number?':
				topic: fishlint.getVersion 1
				'Should result in a short version number x.x.x-x': (topic) ->
					assert.match topic, /[0-9]+.[0-9]+.[0-9]+[0-9a-z-]*/

			'long string?':
				topic: fishlint.getVersion 2
				'Should result in a long version number fishlint vx.x.x-x': (topic) ->
					assert.match topic, /fishlint v[0-9]+.[0-9]+.[0-9]+[0-9a-z-]*/
.export(module)

vows
	.describe('fishlint linting actions')
	.addBatch
		'Linting should':
			'pass?':
				topic: ->
					fishlint.lint [process.cwd() + '/test/pond/good.fish'], this.callback
					return
				'Should result in OK': (err, lines) ->
					assert.isNull err
					assert.match lines[0].mes, /OK/

			'warn?':
				topic: ->
					fishlint.lint ['test/pond/bad.fish'], this.callback
					return
				'Should result in Unknown Command Warning': (err, lines) ->
					assert.isNull err
					assert.match lines[0].mes, /Unknown command/

			'fail parsing?':
				topic: ->
					fishlint.lint ['test/pond/unbalanced.fish'], this.callback
					return
				'Should result in an Unexpected end of string warning': (err, lines) ->
					assert.isNull err
					assert.match lines[0].mes, /Unexpected end of string/
.export(module)
