 				resp.writeHead status
 				resp.end()
 
-describe 'Tests against server mock', ->
+describe 'calling the lib against the server mock', ->
 	server = {}
 
 	before ->

url = require 'url'
path = require 'path'
fs = require 'fs'
expect = require('chai').expect

hm = require '../lib/index'


	after ->
        server.close()

	it 'should return success for urls like 200' , (done) ->
		rp('http://localhost:4000/200')
            .then ->
                done()
            .catch ->
                done(new Error('A 200 response should resolve, not reject'))

	it 'should return the xml for the ccu urls' , (cb) ->
		fname = path.join __dirname, "resources/programlist.xml"
		xml = fs.readFileSync fname, 'UTF-8'

		rp('http://localhost:4000/config/xmlapi/programlist.cgi')
		.then (result) ->
			result.should.equal xml
			cb()
		.catch (err) ->
			cb err


	it 'should return a parsed program list when calling getprograms', (cb) ->
		parsedprogs = [
			{ id: '1681', name: 'first program' },
  			{ id: '1653', name: 'second program' }
		]

		hm.getPrograms(ccu, false)
		.then (result) ->
			result.should.deep.equal parsedprogs
			cb()
		.catch (err) ->
			cb err

	it 'should return the xml for getPrograms with raw flag' , (cb) ->
		fname = path.join __dirname, "resources/programlist.xml"
		xml = fs.readFileSync fname, 'UTF-8'

		xml2js.parseStringAsync(xml).then (expectation) ->
			hm.getPrograms(ccu, true)
			.then (result) ->
				result.should.deep.equal expectation
				cb()
			.catch (err) ->
				cb err



