Added tests
This commit is contained in:
parent
38112e4788
commit
cdea0d989f
5 changed files with 273 additions and 37 deletions
test
58
test/api.js
Normal file
58
test/api.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
var cheerio = require('cheerio');
|
||||
var chai = require('chai');
|
||||
var chaiHttp = require('chai-http');
|
||||
var chaiCheerio = require('chai-cheerio');
|
||||
var server = require('../server');
|
||||
var should = chai.should();
|
||||
|
||||
chai.use(chaiHttp);
|
||||
chai.use(chaiCheerio);
|
||||
|
||||
describe('Api', () => {
|
||||
|
||||
describe('/GET home', () => {
|
||||
it('it should GET the homepage', (done) => {
|
||||
chai.request(server)
|
||||
.get('/')
|
||||
.end((err, res) => {
|
||||
res.should.have.status(200);
|
||||
res.should.be.html;
|
||||
var $ = cheerio.load(res.text);
|
||||
$("#app").should.exist;
|
||||
$("main").should.have.class('home');
|
||||
$("nav.navigation").should.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('/GET github-feed', () => {
|
||||
it('it should GET the github-feed', (done) => {
|
||||
chai.request(server)
|
||||
.get('/github-feed')
|
||||
.end((err, res) => {
|
||||
res.should.have.status(200);
|
||||
res.body.should.be.a('array');
|
||||
res.body.length.should.be.eql(10);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('/GET sitemap', () => {
|
||||
it('it should GET the sitemap', (done) => {
|
||||
chai.request(server)
|
||||
.get('/sitemap.html')
|
||||
.end((err, res) => {
|
||||
res.should.have.status(200);
|
||||
res.should.be.html;
|
||||
var $ = cheerio.load(res.text);
|
||||
$("#app").should.exist;
|
||||
$("#sitemap").should.exist;
|
||||
$("#sitemap").should.have.descendants("li");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue