function match(message, headers) {
	for (let header in headers) {
		if (message.headers[header] !== headers[header]) {
			return false;
		}
	}
	return true;
}

function body(message) {
	if (message["body"] !== undefined) {
		if (message["body"][0]["content-type"] === "text/plain") {
			return message["body"][0]["content"];
		}
		/* istanbul ignore else */
		if (message["body"][0]["content-type"] === "multipart/signed") {
			return message["body"][0]["content"][0]["content"];
		}
	}
	return undefined;
}

function string(message) {
	let string = "";
	if (message["headers"]["From"] !== undefined) {
		string += "From: " + message["headers"]["From"] + "\n";
	}
	/* istanbul ignore else */
	if (message["headers"]["Date"] !== undefined) {
		string += "Date: " + message["headers"]["Date"] + "\n";
	}
	/* istanbul ignore else */
	if (message["headers"]["Subject"] !== undefined) {
		string += "Subject: " + message["headers"]["Subject"] + "\n";
	}
	if (message["headers"]["To"] !== undefined) {

		string += "To: " + message["headers"]["To"] + "\n";
	}
	if (message["body"] !== undefined) {
		string += "\n";
		string += body(message);
	}
	return string;
}

exports.match = match;
exports.body = body;
exports.string = string;