method.unit.test.js 1.41 KB
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
2
3
const methods = require('../routes/methods')

describe("DB methohds test", () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
4
5
6
7
8
9
10
11
12
13
14

    it('returns a user from DB by email', done => {
        methods.getUserByEmail('rosanny.sihombing@hft-stuttgart.de', function(resp, err){
            try {
                expect(resp).not.toBeNull()
                expect(err).toBeNull()
                done()
            } catch (error) {
                done(error)
            }
        })    
Rosanny Sihombing's avatar
Rosanny Sihombing committed
15
16
    })

Rosanny Sihombing's avatar
Rosanny Sihombing committed
17
18
19
20
21
22
23
24
25
26
    it("returns a user from DB by ID", done => {
        methods.getUserById(10, function(resp, err){
            try {
                expect(resp).not.toBeNull()
                expect(err).toBeNull()
                done()
            } catch (error) {
                done(error)
            }
        })    
Rosanny Sihombing's avatar
Rosanny Sihombing committed
27
28
    })

Rosanny Sihombing's avatar
Rosanny Sihombing committed
29
30
31
32
33
34
35
36
37
    it("checks user email", done => {
        methods.checkUserEmail("test@email.de", function(err, resp){
            try {
                expect(resp).not.toBeNull()
                expect(err).toBeNull()
                done()
            } catch (error) {
                done(error)
            }
Rosanny Sihombing's avatar
Rosanny Sihombing committed
38
39
40
        })
    })

Rosanny Sihombing's avatar
Rosanny Sihombing committed
41
42
43
44
45
46
47
48
49
    it("returns a user by token", done => { 
        methods.checkUserEmail("1abc0qwerty", function(err, resp){ // token = any alphanumeric
            try {
                expect(resp).not.toBeNull()
                expect(err).toBeNull()
                done()
            } catch (error) {
                done(error)
            }
Rosanny Sihombing's avatar
Rosanny Sihombing committed
50
51
52
        })
    })
})