'use strict';

const UnfollowTest = require('./unfollow_test');
const ObjectId = require('mongodb').ObjectId;
const Assert = require('assert');

class ReviewNotFoundTest extends UnfollowTest {

	get description () {
		return 'should redirect to an error page when trying to unfollow a non-existent review by clicking an email link';
	}

	// before the test runs...
	before (callback) {
		super.before(error => {
			if (error) { return callback(error); }
			// substitute an ID for a non-existent review
			this.path = `/no-auth/unfollow-link/review/${ObjectId()}?t=${this.token}`;
			callback();
		});
	}

	validateResponse (data) {
		Assert.equal(data, '/web/unfollow-review-error?error=RAPI-1003', 'improper redirect');
	}
}

module.exports = ReviewNotFoundTest;
