REST Service for POPCORN - ILIAS
alex
3 hours ago 24e2d3d3400dcdc84cd4659d2710e83e97a5700c
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
const expect = require("chai").expect
 
const settings = require("../settings")
 
/////////////////////////////////////////////////////////////////////////
 
function getUrl(ref_id) {
    return `http://localhost:${settings.port}/api/ping?token=${settings.authtoken}`
}
 
const ref_id = 595
 
describe("using the API", function () {
 
    describe("the Route GET /api/ping", function () {
 
        it("should return an answer from php component", async function () {
            const url = getUrl(ref_id)
            console.log(url)
            const res = await fetch(url, {
                method: "GET",
                // body: JSON.stringify({}),
                headers: {
                    'Content-Type': 'application/json', // Indicate JSON data
                },
            })
            const data = await res.json()
            // console.log(data)
 
            expect(data).to.be.a("object")
            expect(data.status).to.equal("ok")
            expect(data.msg).to.equal("pong")
        })
 
    })
 
})
 
/////////////////////////////////////////////////////////////////////////