Skip to content

Commit 3d21f2e

Browse files
committed
tests: add extension to nums file
1 parent 0113d8e commit 3d21f2e

File tree

3 files changed

+51
-48
lines changed

3 files changed

+51
-48
lines changed

test/fixtures/no_ext

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foobar

test/send.js

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('send(file).pipe(res)', function () {
7878
.pipe(res)
7979
})
8080
request(app)
81-
.get('/nums')
81+
.get('/name.txt')
8282
.expect(200, '0 - Can\'t set headers after they are sent.', done)
8383
})
8484

@@ -138,7 +138,7 @@ describe('send(file).pipe(res)', function () {
138138
send(req, req.url, {root: fixtures}).pipe(res)
139139
})
140140
request(app)
141-
.get('/nums')
141+
.get('/name.txt')
142142
.expect('Content-Type', 'application/x-custom', done)
143143
})
144144

@@ -200,8 +200,8 @@ describe('send(file).pipe(res)', function () {
200200
})
201201

202202
request(server)
203-
.get('/nums')
204-
.expect(200, '123456789', cb)
203+
.get('/name.txt')
204+
.expect(200, 'tobi', cb)
205205
})
206206

207207
it('should not fire on 404', function (done) {
@@ -253,13 +253,13 @@ describe('send(file).pipe(res)', function () {
253253

254254
function onHeaders (res, filePath) {
255255
assert.ok(filePath)
256-
assert.strictEqual(path.normalize(filePath), path.normalize(path.join(fixtures, 'nums')))
256+
assert.strictEqual(path.normalize(filePath), path.normalize(path.join(fixtures, 'name.txt')))
257257
cb()
258258
}
259259

260260
request(server)
261-
.get('/nums')
262-
.expect(200, '123456789', cb)
261+
.get('/name.txt')
262+
.expect(200, 'tobi', cb)
263263
})
264264

265265
it('should provide stat', function (done) {
@@ -278,8 +278,8 @@ describe('send(file).pipe(res)', function () {
278278
}
279279

280280
request(server)
281-
.get('/nums')
282-
.expect(200, '123456789', cb)
281+
.get('/name.txt')
282+
.expect(200, 'tobi', cb)
283283
})
284284

285285
it('should allow altering headers', function (done) {
@@ -297,12 +297,14 @@ describe('send(file).pipe(res)', function () {
297297
}
298298

299299
request(server)
300-
.get('/nums')
300+
.get('/name.txt')
301+
.expect(200)
301302
.expect('Cache-Control', 'no-cache')
302303
.expect('Content-Type', 'text/x-custom')
303304
.expect('ETag', 'W/"everything"')
304305
.expect('X-Created', dateRegExp)
305-
.expect(200, '123456789', done)
306+
.expect('tobi')
307+
.end(done)
306308
})
307309
})
308310

@@ -557,57 +559,57 @@ describe('send(file).pipe(res)', function () {
557559
describe('with Range request', function () {
558560
it('should support byte ranges', function (done) {
559561
request(app)
560-
.get('/nums')
562+
.get('/nums.txt')
561563
.set('Range', 'bytes=0-4')
562564
.expect(206, '12345', done)
563565
})
564566

565567
it('should ignore non-byte ranges', function (done) {
566568
request(app)
567-
.get('/nums')
569+
.get('/nums.txt')
568570
.set('Range', 'items=0-4')
569571
.expect(200, '123456789', done)
570572
})
571573

572574
it('should be inclusive', function (done) {
573575
request(app)
574-
.get('/nums')
576+
.get('/nums.txt')
575577
.set('Range', 'bytes=0-0')
576578
.expect(206, '1', done)
577579
})
578580

579581
it('should set Content-Range', function (done) {
580582
request(app)
581-
.get('/nums')
583+
.get('/nums.txt')
582584
.set('Range', 'bytes=2-5')
583585
.expect('Content-Range', 'bytes 2-5/9')
584586
.expect(206, done)
585587
})
586588

587589
it('should support -n', function (done) {
588590
request(app)
589-
.get('/nums')
591+
.get('/nums.txt')
590592
.set('Range', 'bytes=-3')
591593
.expect(206, '789', done)
592594
})
593595

594596
it('should support n-', function (done) {
595597
request(app)
596-
.get('/nums')
598+
.get('/nums.txt')
597599
.set('Range', 'bytes=3-')
598600
.expect(206, '456789', done)
599601
})
600602

601603
it('should respond with 206 "Partial Content"', function (done) {
602604
request(app)
603-
.get('/nums')
605+
.get('/nums.txt')
604606
.set('Range', 'bytes=0-4')
605607
.expect(206, done)
606608
})
607609

608610
it('should set Content-Length to the # of octets transferred', function (done) {
609611
request(app)
610-
.get('/nums')
612+
.get('/nums.txt')
611613
.set('Range', 'bytes=2-3')
612614
.expect('Content-Length', '2')
613615
.expect(206, '34', done)
@@ -616,15 +618,15 @@ describe('send(file).pipe(res)', function () {
616618
describe('when last-byte-pos of the range is greater the length', function () {
617619
it('is taken to be equal to one less than the length', function (done) {
618620
request(app)
619-
.get('/nums')
621+
.get('/nums.txt')
620622
.set('Range', 'bytes=2-50')
621623
.expect('Content-Range', 'bytes 2-8/9')
622624
.expect(206, done)
623625
})
624626

625627
it('should adapt the Content-Length accordingly', function (done) {
626628
request(app)
627-
.get('/nums')
629+
.get('/nums.txt')
628630
.set('Range', 'bytes=2-50')
629631
.expect('Content-Length', '7')
630632
.expect(206, done)
@@ -634,7 +636,7 @@ describe('send(file).pipe(res)', function () {
634636
describe('when the first- byte-pos of the range is greater length', function () {
635637
it('should respond with 416', function (done) {
636638
request(app)
637-
.get('/nums')
639+
.get('/nums.txt')
638640
.set('Range', 'bytes=9-50')
639641
.expect('Content-Range', 'bytes */9')
640642
.expect(416, done)
@@ -644,7 +646,7 @@ describe('send(file).pipe(res)', function () {
644646
describe('when syntactically invalid', function () {
645647
it('should respond with 200 and the entire contents', function (done) {
646648
request(app)
647-
.get('/nums')
649+
.get('/nums.txt')
648650
.set('Range', 'asdf')
649651
.expect(200, '123456789', done)
650652
})
@@ -653,15 +655,15 @@ describe('send(file).pipe(res)', function () {
653655
describe('when multiple ranges', function () {
654656
it('should respond with 200 and the entire contents', function (done) {
655657
request(app)
656-
.get('/nums')
658+
.get('/nums.txt')
657659
.set('Range', 'bytes=1-1,3-')
658660
.expect(shouldNotHaveHeader('Content-Range'))
659661
.expect(200, '123456789', done)
660662
})
661663

662664
it('should respond with 206 is all ranges can be combined', function (done) {
663665
request(app)
664-
.get('/nums')
666+
.get('/nums.txt')
665667
.set('Range', 'bytes=1-2,3-5')
666668
.expect('Content-Range', 'bytes 1-5/9')
667669
.expect(206, '23456', done)
@@ -671,13 +673,13 @@ describe('send(file).pipe(res)', function () {
671673
describe('when if-range present', function () {
672674
it('should respond with parts when etag unchanged', function (done) {
673675
request(app)
674-
.get('/nums')
676+
.get('/nums.txt')
675677
.expect(200, function (err, res) {
676678
if (err) return done(err)
677679
var etag = res.headers.etag
678680

679681
request(app)
680-
.get('/nums')
682+
.get('/nums.txt')
681683
.set('If-Range', etag)
682684
.set('Range', 'bytes=0-0')
683685
.expect(206, '1', done)
@@ -686,13 +688,13 @@ describe('send(file).pipe(res)', function () {
686688

687689
it('should respond with 200 when etag changed', function (done) {
688690
request(app)
689-
.get('/nums')
691+
.get('/nums.txt')
690692
.expect(200, function (err, res) {
691693
if (err) return done(err)
692694
var etag = res.headers.etag.replace(/"(.)/, '"0$1')
693695

694696
request(app)
695-
.get('/nums')
697+
.get('/nums.txt')
696698
.set('If-Range', etag)
697699
.set('Range', 'bytes=0-0')
698700
.expect(200, '123456789', done)
@@ -701,13 +703,13 @@ describe('send(file).pipe(res)', function () {
701703

702704
it('should respond with parts when modified unchanged', function (done) {
703705
request(app)
704-
.get('/nums')
706+
.get('/nums.txt')
705707
.expect(200, function (err, res) {
706708
if (err) return done(err)
707709
var modified = res.headers['last-modified']
708710

709711
request(app)
710-
.get('/nums')
712+
.get('/nums.txt')
711713
.set('If-Range', modified)
712714
.set('Range', 'bytes=0-0')
713715
.expect(206, '1', done)
@@ -716,13 +718,13 @@ describe('send(file).pipe(res)', function () {
716718

717719
it('should respond with 200 when modified changed', function (done) {
718720
request(app)
719-
.get('/nums')
721+
.get('/nums.txt')
720722
.expect(200, function (err, res) {
721723
if (err) return done(err)
722724
var modified = Date.parse(res.headers['last-modified']) - 20000
723725

724726
request(app)
725-
.get('/nums')
727+
.get('/nums.txt')
726728
.set('If-Range', new Date(modified).toUTCString())
727729
.set('Range', 'bytes=0-0')
728730
.expect(200, '123456789', done)
@@ -731,7 +733,7 @@ describe('send(file).pipe(res)', function () {
731733

732734
it('should respond with 200 when invalid value', function (done) {
733735
request(app)
734-
.get('/nums')
736+
.get('/nums.txt')
735737
.set('If-Range', 'foo')
736738
.set('Range', 'bytes=0-0')
737739
.expect(200, '123456789', done)
@@ -742,26 +744,26 @@ describe('send(file).pipe(res)', function () {
742744
describe('when "options" is specified', function () {
743745
it('should support start/end', function (done) {
744746
request(createServer({root: fixtures, start: 3, end: 5}))
745-
.get('/nums')
747+
.get('/nums.txt')
746748
.expect(200, '456', done)
747749
})
748750

749751
it('should adjust too large end', function (done) {
750752
request(createServer({root: fixtures, start: 3, end: 90}))
751-
.get('/nums')
753+
.get('/nums.txt')
752754
.expect(200, '456789', done)
753755
})
754756

755757
it('should support start/end with Range request', function (done) {
756758
request(createServer({root: fixtures, start: 0, end: 2}))
757-
.get('/nums')
759+
.get('/nums.txt')
758760
.set('Range', 'bytes=-2')
759761
.expect(206, '23', done)
760762
})
761763

762764
it('should support start/end with unsatisfiable Range request', function (done) {
763765
request(createServer({root: fixtures, start: 0, end: 2}))
764-
.get('/nums')
766+
.get('/nums.txt')
765767
.set('Range', 'bytes=5-9')
766768
.expect('Content-Range', 'bytes */3')
767769
.expect(416, done)
@@ -777,7 +779,7 @@ describe('send(file).pipe(res)', function () {
777779
})
778780

779781
request(app)
780-
.get('/nums')
782+
.get('/name.txt')
781783
.expect(shouldNotHaveHeader('ETag'))
782784
.expect(200, done)
783785
})
@@ -918,14 +920,14 @@ describe('send(file, options)', function () {
918920
describe('acceptRanges', function () {
919921
it('should support disabling accept-ranges', function (done) {
920922
request(createServer({acceptRanges: false, root: fixtures}))
921-
.get('/nums')
923+
.get('/nums.txt')
922924
.expect(shouldNotHaveHeader('Accept-Ranges'))
923925
.expect(200, done)
924926
})
925927

926928
it('should ignore requested range', function (done) {
927929
request(createServer({acceptRanges: false, root: fixtures}))
928-
.get('/nums')
930+
.get('/nums.txt')
929931
.set('Range', 'bytes=0-2')
930932
.expect(shouldNotHaveHeader('Accept-Ranges'))
931933
.expect(shouldNotHaveHeader('Content-Range'))
@@ -936,14 +938,14 @@ describe('send(file, options)', function () {
936938
describe('cacheControl', function () {
937939
it('should support disabling cache-control', function (done) {
938940
request(createServer({cacheControl: false, root: fixtures}))
939-
.get('/nums')
941+
.get('/name.txt')
940942
.expect(shouldNotHaveHeader('Cache-Control'))
941943
.expect(200, done)
942944
})
943945

944946
it('should ignore maxAge option', function (done) {
945947
request(createServer({cacheControl: false, maxAge: 1000, root: fixtures}))
946-
.get('/nums')
948+
.get('/name.txt')
947949
.expect(shouldNotHaveHeader('Cache-Control'))
948950
.expect(200, done)
949951
})
@@ -952,7 +954,7 @@ describe('send(file, options)', function () {
952954
describe('etag', function () {
953955
it('should support disabling etags', function (done) {
954956
request(createServer({etag: false, root: fixtures}))
955-
.get('/nums')
957+
.get('/name.txt')
956958
.expect(shouldNotHaveHeader('ETag'))
957959
.expect(200, done)
958960
})
@@ -1017,7 +1019,7 @@ describe('send(file, options)', function () {
10171019
describe('lastModified', function () {
10181020
it('should support disabling last-modified', function (done) {
10191021
request(createServer({lastModified: false, root: fixtures}))
1020-
.get('/nums')
1022+
.get('/name.txt')
10211023
.expect(shouldNotHaveHeader('Last-Modified'))
10221024
.expect(200, done)
10231025
})
@@ -1046,7 +1048,7 @@ describe('send(file, options)', function () {
10461048

10471049
it('should reject bad value', function (done) {
10481050
request(createServer({dotfiles: 'bogus'}))
1049-
.get('/nums')
1051+
.get('/name.txt')
10501052
.expect(500, /dotfiles/, done)
10511053
})
10521054

@@ -1434,7 +1436,7 @@ describe('send.mime', function () {
14341436
send.mime.default_type = 'text/plain'
14351437

14361438
request(createServer({root: fixtures}))
1437-
.get('/nums')
1439+
.get('/no_ext')
14381440
.expect('Content-Type', 'text/plain; charset=UTF-8')
14391441
.expect(200, done)
14401442
})
@@ -1443,7 +1445,7 @@ describe('send.mime', function () {
14431445
send.mime.default_type = undefined
14441446

14451447
request(createServer({root: fixtures}))
1446-
.get('/nums')
1448+
.get('/no_ext')
14471449
.expect(shouldNotHaveHeader('Content-Type'))
14481450
.expect(200, done)
14491451
})

0 commit comments

Comments
 (0)