var main = require('../package.json').main;
var schedule = require('../' + main);

module.exports = {
	"Job constructor": {
		"Accepts Job name and function to run": function(test) {
			var job = new schedule.Job('the job', function(){});

			test.equal(job.name, 'the job');
			test.done();
		},
		"Job name is optional and will be auto-generated": function(test) {
			var job = new schedule.Job();

			test.ok(job.name);
			test.done();
		},
		"Uses unique names across auto-generated Job names": function(test) {
			var job1 = new schedule.Job();
			var job2 = new schedule.Job();

			test.notEqual(job1.name, job2.name);
			test.done();
		}
	},
	"#schedule(Date)": {
		"Runs job once at some date": function(test) {
			test.expect(1);

			var job = new schedule.Job(function() {
				test.ok(true);
			});

			job.schedule(new Date(Date.now() + 3000));

			setTimeout(function() {
				test.done();
			}, 3250);
		},
		/* No jobs will run after this test for some reason - hide for now
		"Won't run job if scheduled in the past": function(test) {
			test.expect(0);

			var job = new schedule.Job(function() {
				test.ok(true);
			});

			job.schedule(new Date(Date.now() - 3000));

			setTimeout(function() {
				test.done();
			}, 1000);
		},*/
		"Emits 'scheduled' event with 'run at' Date": function(test) {
			test.expect(1);

			var date = new Date(Date.now() + 3000);
			var job = new schedule.Job();

			job.on('scheduled', function(runAtDate) {
				test.equal(runAtDate, date);
			});

			job.schedule(date);

			setTimeout(function() {
				test.done();
			}, 3250);
		}
	},
	"When invoked": {
		"Emits 'run' event": function(test) {
			test.expect(1);

			var job = new schedule.Job(function() {});

			job.on('run', function() {
				test.ok(true);
			});

			job.schedule(new Date(Date.now() + 3000));

			setTimeout(function() {
				test.done();
			}, 3250);
		}
	}
}
@@ -1232,24 +1232,461 @@
 %09%09%7D, 1000);%0A
+%09%09%7D,%0A%09%09%22Jobs still run after scheduling a Job in the past%22: function(test) %7B%0A%09%09%09test.expect(1);%0A%0A%09%09%09var pastJob = new schedule.Job(function() %7B%0A%09%09%09%09// Should not run, blow up if it does%0A%09%09%09%09test.ok(false);%0A%09%09%09%7D);%0A%09%09%09pastJob.schedule(new Date(Date.now() - 3000));%0A%0A%09%09%09var job = new schedule.Job(function() %7B%0A%09%09%09%09test.ok(true);%0A%09%09%09%7D);%0A%09%09%09job.schedule(new Date(Date.now() + 3000));%0A%0A%09%09%09setTimeout(function() %7B%0A%09%09%09%09test.done();%0A%09%09%09%7D, 3250);%0A
 %09%09%7D,*/%0A%09%09%22Em

test exposing issue with jobs scheduled in the past