{"size": 503, "ext": "js", "max_stars_repo_path": "test/test-post.js", "max_stars_repo_name": "earlbread/simple-blog-node", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/test-post.js", "max_issues_repo_name": "earlbread/simple-blog-node", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/test-post.js", "max_forks_repo_name": "earlbread/simple-blog-node", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.3461538462, "max_line_length": 60, "alphanum_fraction": 0.5984095427}
const test = require('ava');
const request = require('supertest');
const app = require('../app');
const Post = require('../models/post');

const _post = {
  subject: 'subject',
  content: 'content'
};

test('Create post', async t => {
  t.plan(3);

  const res = await request(app).post('/posts').send(_post);

  t.is(res.status, 200);
  t.is(res.body.subject, 'subject');
  t.is(res.body.content, 'content');
});

test.after('Clean up', () => {
  Post.remove(err => {
    if (err) throw err;
  });
});
