var lintIssues = require('../lib/lintIssues');

describe('lintIssues', function () {
	it('should return warning of an uncommented issue', function () {
		var issues = [
			{
				user: {
					login: 'jimbob'
				},
				comments: 0,
				labels: ['a label'],
				title: 'This issue has no comments',
				html_url: 'This is a URL'
			}
		];

		var report = lintIssues(issues, 'joebloggs');

		report.failures.should.containEql({
			message: 'Uncommented issue',
			details: {
				url: 'This is a URL',
				title: 'This issue has no comments',
				suggestion: 'Comment on the issue to indicate acknowledgement'
			}
		});

		report.failures.length.should.eql(1);
	});

	it('should return no warnings if all issues are commented upon', function () {
		var issues = [
			{
				user: {
					login: 'jimbob'
				},
				comments: 1,
				labels: [],
				title: 'This issue has no comments',
				html_url: 'This is a URL'
			}
		];

		var report = lintIssues(issues, 'joebloggs');

		report.failures.length.should.eql(0);
	});

	it('should return no warnings if all untouched issues were opened by the repo author', function () {
		var issues = [
			{
				user: {
					login: 'joebloggs'
				},
				comments: 0,
				labels: [],
				title: 'This issue has no comments',
				html_url: 'This is a URL'
			}
		];

		var report = lintIssues(issues, 'joebloggs');

		report.failures.length.should.eql(0);
		report.passes.length.should.eql(1);
		report.passes.should.containEql({
			message: 'All open issues have been acknowledged'
		});
	});

	it('should return no warnings if all untouched issues were commented on or labeled', function () {
		var issues = [
			{
				user: {
					login: 'jimbob'
				},
				comments: 1,
				labels: [],
				title: 'This issue has no comments',
				html_url: 'This is a URL'
			},
			{
				user: {
					login: 'jimbob'
				},
				comments: 1,
				labels: ['alabel'],
				title: 'This issue has no comments',
				html_url: 'This is a URL'
			}
		];

		var report = lintIssues(issues, 'joebloggs');

		report.failures.length.should.eql(0);
		report.passes.length.should.eql(1);
		report.passes.should.containEql({
			message: 'All open issues have been acknowledged'
		});
	});

	it('should return warning of an untouched issue and uncommented issue', function () {
		var issues = [
			{
				user: {
					login: 'jimbob'
				},
				comments: 0,
				labels: [],
				title: 'This issue has no comments or labels',
				html_url: 'This is a URL'
			}
		];

		var report = lintIssues(issues, 'joebloggs');

		report.failures.should.containEql({
			message: 'Uncommented issue',
			details: {
				url: 'This is a URL',
				title: 'This issue has no comments or labels',
				suggestion: 'Comment on the issue to indicate acknowledgement'
			}
		});

		report.failures.should.containEql({
			message: 'Untouched issue',
			details: {
				url: 'This is a URL',
				title: 'This issue has no comments or labels',
				suggestion: 'Comment or label the issue to indicate acknowledgement'
			}
		});

		report.failures.length.should.eql(2);
	});
});
@@ -1272,32 +1272,190 @@
 'This is a URL'%0A
+%09%09%09%7D,%0A%09%09%09%7B%0A%09%09%09%09user: %7B%0A%09%09%09%09%09login: 'joeBLOGGS'%0A%09%09%09%09%7D,%0A%09%09%09%09comments: 0,%0A%09%09%09%09labels: %5B%5D,%0A%09%09%09%09title: 'This issue has no comments',%0A%09%09%09%09html_url: 'This is a URL'%0A
 %09%09%09%7D%0A%09%09%5D;%0A%0A%09%09var

add test case for username in different case