Last active
August 28, 2019 14:24
-
-
Save akhilome/04203b7c879458d49170ce49558797ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chai from 'chai'; | |
import 'chai/register-should'; | |
import chaiHttp from 'chai-http'; | |
import app from '../../src/app.js'; | |
import { publications, articles } from '../mockData'; | |
chai.use(chaiHttp); | |
describe('GET all articles for a particular publication', () => { | |
it('should return a 404 if publication does not exist', (done) => { | |
chai.request(app) | |
.get(`/api/${publications.invalid}`) | |
.end((err, res) => { | |
if (err) done(err); | |
res.status.should.eql(404); | |
res.body.message.should.eql('no such publication found'); | |
done(); | |
}); | |
}); | |
it('should return an array containing the publication\'s articles', (done) => { | |
chai.request(app) | |
.get(`/api/${publications.valid}`) | |
.end((err, res) => { | |
if (err) done(err); | |
res.status.should.eql(200); | |
res.body.articles.should.be.an('array'); | |
res.body.articles[0].should.have.all.keys(Object.keys(articles[0])); | |
done(); | |
}); | |
}); | |
}); |
Good job. What does "publications.valid" and "publications.invalid" represent?
Thanks, @marcdomain. 🙏
To your question, publications
, imported on line 6
, is an object which would contain various valid publication names and invalid ones as well. It would essentially take the following form:
const publications = {
valid: 'a-valid-publication',
invalid: 'this-publication-does-not-exist-yet'
};
Thanks for taking time out to go over my work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good job. What does "publications.valid" and "publications.invalid" represent?