const expect = require("chai").expect
|
|
const settings = require("../settings")
|
const libIlias = require("../lib/libIlias")
|
const db = require("../lib/db")
|
const testData = require("./data")
|
|
/////////////////////////////////////////////////////////////////////////
|
|
function getUrl(ref_id) {
|
return `http://localhost:${settings.port}/api/kurs/${ref_id}/offline?token=${settings.authtoken}`
|
}
|
|
const ref_id = 595
|
|
describe("using the API", function () {
|
|
describe("the Route GET /api/kurs/:refId/offline", function () {
|
|
it("should return the offline or online status of a kurs", async function () {
|
const url = getUrl(ref_id)
|
console.log(url)
|
const res = await fetch(url, {
|
method: "GET",
|
// body: JSON.stringify(body),
|
headers: {
|
'Content-Type': 'application/json', // Indicate JSON data
|
},
|
})
|
// console.log(res)
|
const data = await res.json()
|
console.log(data)
|
|
expect(data).to.be.a("object").and.to.have.property("offline")
|
})
|
|
})
|
|
describe("the Route POST /api/kurs/:refId/offline", function () {
|
|
it("should set the offline or online status of a kurs", async function () {
|
const url = getUrl(ref_id)
|
console.log(url)
|
const body = {offline: 0}
|
const res = await fetch(url, {
|
method: "POST",
|
body: JSON.stringify(body),
|
headers: {
|
'Content-Type': 'application/json', // Indicate JSON data
|
},
|
})
|
// console.log(res)
|
const data = await res.json()
|
console.log(data)
|
expect(data).to.be.a("object").and.to.have.property("offline")
|
})
|
|
})
|
|
})
|
|
/////////////////////////////////////////////////////////////////////////
|