/** * @jest-environment node */ import request from 'supertest' import { app } from '../app' describe('Releases helper', () => { it('Should respond with empty array to unknown user agents', async () => { return request(app) .get('/api/apps/android/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('/api/apps/android/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('/api/apps/android/releases') .set('User-Agent', 'Juick/100 okhttp/3.12 Android/24') .expect(302) .then(response => { expect(response.redirect).toBe(true) }) }) })