<commit_before>var testHelpers = require('./testHelpers.js');
var request = testHelpers.request;

describe("The backend API", function(){
	beforeEach(function () { testHelpers.cleanDb(); });

	describe("Families", function() {
		describe("Adding", function () {
			it("adds a new family with all required attributes", function (done) {
				var postData = { name : "Hammarbergs"};

				request
					.post("/api/family")
					.send(postData)
					.expect("location", /^\/api\/family\/[0-9a-fA-F]{24}$/)
					.expect(200, done);
			});
			it("requires a family name", function (done) {
				var postData = { };

				request
					.post("/api/family")
					.send(postData)
					.expect("ErrorMessage", "Family name required")
					.expect(400, done);
			});
			it("requires an unique family name", function (done) {
				testHelpers.insertFamily("Hammarbergs");

				var postData = { name : "Hammarbergs"};

				request
					.post("/api/family")
					.send(postData)
					.expect("ErrorMessage", "Family name taken")
					.expect(400, done);
			});
		});
		describe("Getting", function () {
			it("for an existing family name", function (done) {
				testHelpers.insertFamily("Hammarbergs");

				request
					.get("/api/family/Hammarbergs")
					.set("Accept", "application/json")
					.expect(/Hammarbergs/)
					.expect(200, done);
			});
			it("returns error for non-existing family name", function (done) {
				request
					.get("/api/family/Hammarbergs")
					.set("Accept", "application/json")
					.expect(404, done);
			});
		});
		describe("Updating", function () {
			it("updates family names");
			it("requires unique family name");
			it("adds family members");
			it("require a name for family members");
			it("require a birthdate for family members");
			it("changes name for existing family members");
			it("removes existing family members");
		});
		describe("Remove", function () {
			it("removes all data about a family, including quotes");<commit_msg>Moved the test around a bit for readability<commit_after>var testHelpers = require('./testHelpers.js');
var request = testHelpers.request;

describe("The backend API", function(){
	beforeEach(function () { testHelpers.cleanDb(); });

	describe("Families", function() {
		describe("Adding", function () {
			it("adds a new family with all required attributes", function (done) {
				var postData = { name : "Hammarbergs"};

				request
					.post("/api/family")
					.send(postData)
					.expect("location", /^\/api\/family\/[0-9a-fA-F]{24}$/)
					.expect(200, done);
			});
			it("requires a family name", function (done) {
				var postData = { };

				request
					.post("/api/family")
					.send(postData)
					.expect("ErrorMessage", "Family name required")
					.expect(400, done);
			});
			it("requires an unique family name", function (done) {
				testHelpers.insertFamily("Hammarbergs");

				var postData = { name : "Hammarbergs"};

				request
					.post("/api/family")
					.send(postData)
					.expect("ErrorMessage", "Family name taken")
					.expect(400, done);
			});
		});
		describe("Getting", function () {
			it("for an existing family name", function (done) {
				testHelpers.insertFamily("Hammarbergs");

				request
					.get("/api/family/Hammarbergs")
					.set("Accept", "application/json")
					.expect(/Hammarbergs/)
					.expect(200, done);
			});
			it("returns error for non-existing family name", function (done) {
				request
					.get("/api/family/Hammarbergs")
					.set("Accept", "application/json")
					.expect(404, done);
			});
		});
		describe("Updating", function () {
			it("updates family name");
			it("requires unique family name");
		});
		describe("Adding family members", function() {
			it("adds family members");
			it("require a name for family members");
			it("require a birthdate for family members");
			it("changes name for existing family members");
			it("removes existing family members");
		});
		describe("Remove", function () {
			it("removes all data about a family, including quotes");
{'fraction_non_alphanumeric': 0.16791230692575984, 'fraction_numerical': 0.009466865969108122, 'mean_word_length': 3.364130434782609, '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': '759016', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1199, 'n_words': 310}