<commit_before>
// setup easy references
var mongoose = linz.mongoose,
	formtools = linz.formtools;

describe('formtools', function () {

	var PostSchema,
		Text;

	beforeEach(function () {
		PostSchema = new mongoose.Schema({ label: String });
	});

	it('adds the title virtual', function () {

		PostSchema.plugin(formtools.plugin);

		PostSchema.virtuals.should.have.property('title');
		PostSchema.paths.should.have.property('label');

	});

	it('gracefully handles existing title properties', function () {

		// create the schema
		var TestSchema = new mongoose.Schema({ title: String, label: String, name: String });

		// add the plugin
		TestSchema.plugin(formtools.plugin);

		// create the model and a new instance of the model
		var Test = mongoose.model('TestSchema', TestSchema),
			test = new Test();

		// set the title property
		test.title = 'Title value';

		// assert
		TestSchema.virtuals.should.not.have.property('title');
		test.title.should.equal('Title value');

	});

	it('virtual title returns label property second', function () {

		// create the schema
		var LabelTestSchema = new mongoose.Schema({ label: String, name: String });

		// add the plugin
		LabelTestSchema.plugin(formtools.plugin);

		// create the model and a new instance of the model
		var LabelTest = mongoose.model('LabelTest', LabelTestSchema),
			labeltest = new LabelTest();

		// set the label property
		labeltest.label = 'Title value';

		// assert
		LabelTestSchema.virtuals.should.have.property('title');
		labeltest.title.should.equal('Title value');

	});

	it('virtual title returns name property second', function () {

		// create the schema
		var NameTestSchema = new mongoose.Schema({ label: String, name: String });

		// add the plugin
		NameTestSchema.plugin(formtools.plugin);

		// create the model and a new instance of the model
		var NameTest = mongoose.model('NameTest', NameTestSchema),
			nametest = new NameTest();

		// set the label property
		nametest.name = 'Title value';

		// assert
		NameTestSchema.virtuals.should.have.property('title');
		nametest.title.should.equal('Title value');

	});

});<commit_msg>Added some basic, but first test cases for the form generator.<commit_after>
// setup easy references
var mongoose = linz.mongoose,
	formtools = linz.formtools;

describe('formtools', function () {

	var PostSchema,
		PostModel,
		Text;

	describe('extends the schema', function () {

		beforeEach(function () {
			PostSchema = new mongoose.Schema({ label: String });
		});

		it('it adds the title virtual', function () {

			PostSchema.plugin(formtools.plugin);

			PostSchema.virtuals.should.have.property('title');
			PostSchema.paths.should.have.property('label');

		});

		it('gracefully handles existing title properties', function () {

			// create the schema
			var TestSchema = new mongoose.Schema({ title: String, label: String, name: String });

			// add the plugin
			TestSchema.plugin(formtools.plugin);

			// create the model and a new instance of the model
			var Test = mongoose.model('TestSchema', TestSchema),
				test = new Test();

			// set the title property
			test.title = 'Title value';

			// assert
			TestSchema.virtuals.should.not.have.property('title');
			test.title.should.equal('Title value');

		});

		it('virtual title returns label property second', function () {

			// create the schema
			var LabelTestSchema = new mongoose.Schema({ label: String, name: String });

			// add the plugin
			LabelTestSchema.plugin(formtools.plugin);

			// create the model and a new instance of the model
			var LabelTest = mongoose.model('LabelTest', LabelTestSchema),
				labeltest = new LabelTest();

			// set the label property
			labeltest.label = 'Title value';

			// assert
			LabelTestSchema.virtuals.should.have.property('title');
			labeltest.title.should.equal('Title value');

		});

		it('virtual title returns name property second', function () {

			// create the schema
			var NameTestSchema = new mongoose.Schema({ label: String, name: String });

			// add the plugin
			NameTestSchema.plugin(formtools.plugin);

			// create the model and a new instance of the model
			var NameTest = mongoose.model('NameTest', NameTestSchema),
				nametest = new NameTest();

			// set the label property
			nametest.name = 'Title value';

			// assert
			NameTestSchema.virtuals.should.have.property('title');
			nametest.title.should.equal('Title value');

		});

	});

	describe('scaffolds', function () {

		before(function () {

			PostSchema = new mongoose.Schema({
				label: String,
				subHeading: String
			});

			PostSchema.plugin(formtools.plugin, {
				forms: {
					label: {
						label: 'Label'
					},
					subHeading: {
						label: 'Sub heading'
					},
					edit: {
						dateCreated: {
							visible: true,
							disabled: true
						}
					}
				}
			});

			PostModel = mongoose.model('PostModel', PostSchema);

		});

		describe('create forms', function () {

			describe('for each field', function () {

				var formOpts;

				beforeEach(function (done) {

					PostModel.getForm(function (err, result) {
						formOpts = result;
						done();
					});

				});

				it('should set the label', function () {
					formOpts['label'].label.should.equal('Label');
				});

				it('should default visible to true', function () {
					formOpts['label'].visible.should.be.true;
				});

			});

		});

	});

});
{'fraction_non_alphanumeric': 0.13448020717721051, 'fraction_numerical': 0.0, 'mean_word_length': 3.308366533864542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3596005', 'n_tokens_mistral': 1895, 'n_tokens_neox': 1567, 'n_words': 432}