"use strict";

var roads = require('../index');
var url_module = require('url');

/**
 * Test that getData with a promise is still the original promise
 */
exports.testPromiseGetData = function (test) {
	var response_data = {
		message : "hello"
	};

	var promise = new roads.Promise(function (resolve, reject) {
		resolve(response_data);
	});

	var res = new roads.Response(promise);

	test.equal(promise, res.getData());
	test.done();
};

/**
 * Test that getData with a non promise is translated into a promise
 */
exports.testPromiseGetData = function (test) {
	var response_data = {
		message : "hello"
	};

	var res = new roads.Response(response_data);

	test.true(response_data, res.getData());
	test.done();
};

/**
 * Test that a response built around a promise is thenable, and returns the original data
 */
exports.testPromiseGetData = function (test) {
	var response_data = {
		message : "hello"
	};

	var promise = new roads.Promise(function (resolve, reject) {
		resolve(response_data);
	});

	var res = new roads.Response(promise);

	res.data.then(function (data) {
		test.equal(data, response_data);
		test.done();
	});
};

/**
 * Ensure that a response built around direct data (not a promise) becomes a promise, is thenable, and returns the original data
 */
exports.testNonPromiseGetData = function (test) {
	var response_data = {
		message : "hello"
	};

	var res = new roads.Response(response_data);

	test.equal(res.data, response_data);
	test.done();
};
@@ -378,17 +378,16 @@
 omise);%0A
-%0A
 %09test.eq
@@ -399,33 +399,28 @@
 romise, res.
-getD
+d
 ata
-()
 );%0A%09test.don
@@ -513,33 +513,32 @@
 exports.test
-PromiseGe
+GetObjec
 tData = func
@@ -656,12 +656,13 @@
 est.
-true
+equal
 (res
@@ -681,17 +681,12 @@
 res.
-getD
+d
 ata
-()
 );%0A%09
@@ -808,38 +808,41 @@
 exports.test
-Promise
 GetData
+IsThenable
  = function 

fix some unit tests