blob: 448714ac20e00c34a7b1002b826869af3b2e761e (
plain) (
blame)
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
|
import request from 'supertest'
import express from 'express'
import releases from './android'
const app = express()
app.get('/releases', releases)
describe('Releases helper', () => {
it('Should respond with empty array to unknown user agents', async () => {
return request(app)
.get('/releases')
.expect(200)
.then(response => {
expect(response.body).toStrictEqual([])
})
})
it('Should respond with a single legacy version data to old Android app', async () => {
return request(app)
.get('/releases')
.set('User-Agent', 'Juick/100 okhttp/3.12 Android/19')
.expect(200)
.then(response => {
expect(response.body.length).toBe(1)
expect(response.body[0].name).toBe('3.1.216')
})
})
it('Should redirect to Github when Android version is ok', async () => {
return request(app)
.get('/releases')
.set('User-Agent', 'Juick/100 okhttp/3.12 Android/24')
.expect(302)
.then(response => {
expect(response.redirect).toBe(true)
})
})
})
|