mirror of
https://github.com/devfake/flox.git
synced 2024-11-14 22:22:39 +01:00
9d2362a178
Add setup More tests Refactoring Update readme Update json format Bump Refactor Add ext property for episodes Update README.md Add subtitles Add code coverage Add movies Add tv and movie api request Add env variables for root paths Clean up Merge all GET requests into one Clean up
130 lines
3.3 KiB
JavaScript
130 lines
3.3 KiB
JavaScript
import { expect } from "chai"
|
|
|
|
describe("HTTP Server", () => {
|
|
beforeEach(() => {
|
|
process.env.TV_ROOT = __dirname + "/fixtures/tv"
|
|
process.env.MOVIES_ROOT = __dirname + "/fixtures/movies"
|
|
})
|
|
|
|
describe("GET: fetch", () => {
|
|
const path = "/fetch"
|
|
|
|
it("should succeed", (done) => {
|
|
request.get(path)
|
|
.expect(200, done)
|
|
})
|
|
|
|
it("returns valid json", (done) => {
|
|
request.get(path)
|
|
.expect('Content-Type', /json/)
|
|
.end((err, res) => {
|
|
if(err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it("should contain movies", (done) => {
|
|
request.get(path)
|
|
.expect(res => {
|
|
const stringified = JSON.stringify(res.body)
|
|
|
|
expect(stringified).to.match(/Warcraft/)
|
|
expect(stringified).to.match(/Star Wars/)
|
|
expect(res.body).to.have.property("movies")
|
|
expect(res.body).to.be.a("object")
|
|
})
|
|
.end((err) => {
|
|
if (err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it("should contain tv", (done) => {
|
|
request.get(path)
|
|
.expect(res => {
|
|
const stringified = JSON.stringify(res.body)
|
|
|
|
expect(stringified).to.match(/season/)
|
|
expect(res.body).to.have.property("tv")
|
|
expect(res.body).to.be.a("object")
|
|
})
|
|
.end((err) => {
|
|
if (err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
|
|
describe("GET: fetch/tv", () => {
|
|
const path = "/fetch/tv"
|
|
|
|
it("should succeed", (done) => {
|
|
request.get(path)
|
|
.expect(200, done)
|
|
})
|
|
|
|
it("returns valid json", (done) => {
|
|
request.get(path)
|
|
.expect('Content-Type', /json/)
|
|
.end((err, res) => {
|
|
if(err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it("should only include tv", (done) => {
|
|
request.get(path)
|
|
.expect(res => {
|
|
const stringified = JSON.stringify(res.body)
|
|
|
|
expect(stringified).to.match(/season/)
|
|
expect(stringified).to.not.match(/Warcraft/)
|
|
expect(stringified).to.not.match(/Star Wars/)
|
|
expect(res.body).to.not.have.property("tv")
|
|
expect(res.body).to.not.have.property("movies")
|
|
expect(res.body).to.be.a("array")
|
|
})
|
|
.end((err) => {
|
|
if (err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
|
|
describe("GET: fetch/movies", () => {
|
|
const path = "/fetch/movies"
|
|
|
|
it("should succeed", (done) => {
|
|
request.get(path)
|
|
.expect(200, done)
|
|
})
|
|
|
|
it("returns valid json", (done) => {
|
|
request.get(path)
|
|
.expect('Content-Type', /json/)
|
|
.end((err, res) => {
|
|
if(err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it("should only include movies", (done) => {
|
|
request.get(path)
|
|
.expect(res => {
|
|
const stringified = JSON.stringify(res.body)
|
|
|
|
expect(stringified).to.not.match(/season/)
|
|
expect(stringified).to.match(/Warcraft/)
|
|
expect(stringified).to.match(/Star Wars/)
|
|
expect(res.body).to.not.have.property("tv")
|
|
expect(res.body).to.not.have.property("movies")
|
|
expect(res.body).to.be.a("array")
|
|
})
|
|
.end((err) => {
|
|
if (err) return done(err)
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
})
|