<commit_before>import expect from 'expect';
import request from 'supertest';
import app from '../app';
import models from '../server/models';

let recipeId;
let userId;

const doBeforeAll = () => {
  before((done) => {
    models.favoriteRecipes.destroy({
      cascade: true,
      truncate: true,
      restartIdentity: true
    });
    done();
  });
};
const doBeforeEach = () => {
  beforeEach((done) => {
    models.sequelize.sync();
    done();
  });
};

describe('More-Recipe API: ', () => {
  doBeforeAll();
  doBeforeEach();
  it('should sign user in', (done) => {
    request(app)
      .post('/api/v1/users/signin')
      .send({
        username: 'testuser1',
        password: '<PASSWORD>',
      })
      .expect(201)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
        userId = res.body.data.userId;
        expect(res.body.message).toBe('You have successfully signed in!');
        done();
      });
  });
  it('should be able to add recipe providing a token', (done) => {
    request(app)
      .post('/api/v1/recipes')
      .send({
        recipeName: 'Pizza',
        ingredient: 'pepper, flour, onions',
        details: 'grind pepper and onion then bake',
        token: '<KEY>'
      })
      .expect(201)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
        recipeId = res.body.recipeId;
        expect(res.body.message).toBe('Recipe added successfully');
        done();
      });
  });
  it('should be able to get favorite recipes', (done) => {
    request(app)
      .get(`/api/v1/users/${userId}/recipes`)
      .send({
        token: '<KEY>'
      })
      .expect(404)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
        expect(res.body.message).toBe('No favorite recipe found');
        done();
      });
  });
  it('should be able to add favorite recipes', (done) => {
    request(app)
      .post(`/api/v1/users/${recipeId}/recipes`)
      .send({
        userId: `${userId}`,
        token: '<KEY>'
      })
      .expect(201)
      .end((err, res) => {
        if (err) {
          return done(err);
        }<commit_msg>Edit test<commit_after>import expect from 'expect';
import request from 'supertest';
import app from '../app';
import models from '../server/models';

let recipeId;
let userId;

const doBeforeAll = () => {
  before((done) => {
    models.favoriteRecipes.destroy({
      cascade: true,
      truncate: true,
      restartIdentity: true
    });
    done();
  });
};
const doBeforeEach = () => {
  beforeEach((done) => {
    models.sequelize.sync();
    done();
  });
};

describe('More-Recipe API: ', () => {
  doBeforeAll();
  doBeforeEach();
  it('should sign user in', (done) => {
    request(app)
      .post('/api/v1/users/signin')
      .send({
        username: 'testuser1',
        password: '<PASSWORD>',
      })
      .expect(201)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
        userId = res.body.data.userId;
        expect(res.body.message).toBe('You have successfully signed in!');
        done();
      });
  });
  it('should be able to add recipe providing a token', (done) => {
    request(app)
      .post('/api/v1/recipes')
      .send({
        recipeName: 'Pizza',
        ingredient: 'pepper, flour, onions',
        details: 'grind pepper and onion then bake',
        token: '<KEY>'
      })
      .expect(201)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
        recipeId = res.body.recipeId;
        expect(res.body.message).toBe('Recipe added successfully');
        done();
      });
  });
  it('should not be able to get favorite recipes that does not exist', (done) => {
    request(app)
      .get(`/api/v1/users/${userId}/recipes`)
      .send({
        token: '<KEY>'
      })
      .expect(404)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
        expect(res.body.message).toBe('No favorite recipe found');
        done();
      });
  });
  it('should be able to add favorite recipes', (done) => {
    request(app)
      .post(`/api/v1/users/${recipeId}/recipes`)
      .send({
        userId: `${userId}`,
        token: '<KEY>'
      })
      .expect(201)
      .end((err, res) => {
        if (err) {
          return done(err);
        }
{'fraction_non_alphanumeric': 0.17848970251716248, 'fraction_numerical': 0.007780320366132723, 'mean_word_length': 1.9754935330156569, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '1646409', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1413, 'n_words': 316}