REST Service for POPCORN - ILIAS
alex
2 hours ago edcf6061e5efbe1b60bc1d17ff4bbe83ae866a09
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
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 POST /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: "POST",
                body: JSON.stringify({}),
                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")
            expect(data.status).to.equal("ok")
            expect(data.msg).to.equal("pong")
        })
 
    })
 
})
 
/////////////////////////////////////////////////////////////////////////