From 5f07206c058a7dd431c29ba1b422af6f489528da Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Sat, 4 Feb 2023 10:51:59 +0100 Subject: [PATCH] test concurrent download --- server/api/font/font.spec.js | 48 ++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/server/api/font/font.spec.js b/server/api/font/font.spec.js index 3ebb6a7..812a62a 100644 --- a/server/api/font/font.spec.js +++ b/server/api/font/font.spec.js @@ -4,28 +4,28 @@ var should = require('should'); var app = require('../../app'); var request = require('supertest'); -describe('GET /api/fonts', function() { +describe('GET /api/fonts', function () { - it('should respond with JSON array with all fonts', function(done) { + it('should respond with JSON array with all fonts', function (done) { request(app) .get('/api/fonts') .timeout(10000) .expect(200) .expect('Content-Type', /json/) - .end(function(err, res) { + .end(function (err, res) { if (err) return done(err); res.body.should.be.instanceof(Array); done(); }); }); - it('should respond with font files for arvo', function(done) { + it('should respond with font files for arvo', function (done) { request(app) .get('/api/fonts/arvo') .timeout(10000) .expect(200) .expect('Content-Type', /json/) - .end(function(err, res) { + .end(function (err, res) { if (err) return done(err); res.body.should.be.instanceof(Object); // res.body.should.be.instanceof(Array); @@ -33,4 +33,42 @@ describe('GET /api/fonts', function() { }); }); + it('should (concurrently) download istok-web', function (done) { + + var triggered = 0; + + request(app) + .get('/api/fonts/istok-web?download=zip&subsets=latin&formats=eot,woff,woff2,svg,ttf') + .timeout(10000) + .expect(200) + .expect('Content-Type', "application/zip") + .end(function (err, res) { + if (err) { + return done(err); + } + + triggered += 1; + if (triggered === 2) { + done(); + } + }); + + request(app) + .get('/api/fonts/istok-web?download=zip&subsets=latin&formats=eot,woff,woff2,svg,ttf') + .timeout(10000) + .expect(200) + .expect('Content-Type', "application/zip") + .end(function (err, res) { + if (err) { + return done(err); + } + + triggered += 1; + if (triggered === 2) { + done(); + } + }); + + }); + });