aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/android.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server/middleware/android.spec.js')
-rw-r--r--vnext/server/middleware/android.spec.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/vnext/server/middleware/android.spec.js b/vnext/server/middleware/android.spec.js
new file mode 100644
index 00000000..19d380d7
--- /dev/null
+++ b/vnext/server/middleware/android.spec.js
@@ -0,0 +1,33 @@
+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)
+ })
+ })
+})