<commit_before>"use strict";

var request   = require("supertest"),
    serverApp = require("../server-app");

request = request(serverApp);

describe("Persons collection", function () {

  describe("list collection", function () {

    it("should return empty list", function (done) {
      request
        .get("/api/persons")
        .expect(200)
        .expect([])
        .end(done);
    });

  });

  describe("post to collection", function () {

    it("should create entry and redirect when valid", function (done) {
      // FIXME - data is not currently being saved. Need to check tha it will be.
      request
        .post("/api/persons")
        .send({ name: "<NAME>" })
        .expect(201)
        .expect('')
        .expect('Location', /^\/api\/persons\/[0-9a-f]{24}$/)
        .end(done);
    });

    it("should error when not valid", function (done) {
      request
        .post("/api/persons")
        .send({ name: 123, meme: "<NAME>" }) // name should be string
        .expect(400)
        .expect("Content-Type", "application/json; charset=utf-8")
        .expect({
          errors: [ "Error 'Instance is not a required type' with 'http://popoloproject.com/schemas/person.json#/properties/name'." ]
        })
        .end(done);
    });

    it("should error when not valid", function (done) {
      request
        .post("/api/persons")
        .send({ meme: "<NAME>" }) // no name
        .expect(400)
        .expect("Content-Type", "application/json; charset=utf-8")
        .expect({
          errors: [ "Error 'Property is required' with 'http://popoloproject.com/schemas/person.json#/properties/name'." ]
        })
        .end(done);
    });

  });
<commit_msg>Better test wording<commit_after>"use strict";

var request   = require("supertest"),
    serverApp = require("../server-app");

request = request(serverApp);

describe("Persons collection", function () {

  describe("list collection", function () {

    it("should return empty list", function (done) {
      request
        .get("/api/persons")
        .expect(200)
        .expect([])
        .end(done);
    });

  });

  describe("post to collection", function () {

    it("should create entry and return Location when valid", function (done) {
      // FIXME - data is not currently being saved. Need to check that it will be.
      request
        .post("/api/persons")
        .send({ name: "<NAME>" })
        .expect(201)
        .expect('')
        .expect('Location', /^\/api\/persons\/[0-9a-f]{24}$/)
        .end(done);
    });

    it("should error when not valid (bad name)", function (done) {
      request
        .post("/api/persons")
        .send({ name: 123, meme: "<NAME>" }) // name should be string
        .expect(400)
        .expect("Content-Type", "application/json; charset=utf-8")
        .expect({
          errors: [ "Error 'Instance is not a required type' with 'http://popoloproject.com/schemas/person.json#/properties/name'." ]
        })
        .end(done);
    });

    it("should error when not valid (missing name)", function (done) {
      request
        .post("/api/persons")
        .send({ meme: "<NAME>" }) // no name
        .expect(400)
        .expect("Content-Type", "application/json; charset=utf-8")
        .expect({
          errors: [ "Error 'Property is required' with 'http://popoloproject.com/schemas/person.json#/properties/name'." ]
        })
        .end(done);
    });

  });

{'fraction_non_alphanumeric': 0.1744186046511628, 'fraction_numerical': 0.012209302325581395, 'mean_word_length': 2.2098880597014925, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7412766', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1006, 'n_words': 255}