REST Service for POPCORN - ILIAS
alex
2025-11-17 3d646156c378c6182e55c673c118c23d53ff0a05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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")
        })
 
    })
 
})
 
/////////////////////////////////////////////////////////////////////////