Skip to content

Commit

Permalink
add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Nov 21, 2024
1 parent 41454ea commit 027649c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/send.1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const http = require('node:http')
const path = require('node:path')
const request = require('supertest')
const send = require('..').send
const { shouldNotHaveHeader, shouldHaveHeader, createServer } = require('./utils')
const { shouldNotHaveHeader, createServer } = require('./utils')

// test server

Expand Down Expand Up @@ -44,8 +44,8 @@ test('send(file, options)', function (t) {
request(createServer({ acceptRanges: true, maxChunkSize: 1, root: fixtures }))
.get('/nums.txt')
.set('Range', 'bytes=0-2')
.expect(shouldHaveHeader('Accept-Ranges', t))
.expect(shouldHaveHeader('Content-Range', t))
.expect((res) => t.equal(res.headers['accept-ranges'], 'bytes'))
.expect((res) => t.equal(res.headers['content-range'], 'bytes 0-0/9'))
.expect((res) => t.equal(res.headers['content-length'], '1', 'should content-length must be as same as maxChunkSize'))
.expect(206, '1', (err) => t.error(err))
})
Expand All @@ -56,8 +56,8 @@ test('send(file, options)', function (t) {
request(createServer({ acceptRanges: true, maxChunkSize: 1, root: fixtures }))
.get('/nums.txt')
.set('Range', 'bytes=1-2')
.expect(shouldHaveHeader('Accept-Ranges', t))
.expect(shouldHaveHeader('Content-Range', t))
.expect((res) => t.equal(res.headers['accept-ranges'], 'bytes'))
.expect((res) => t.equal(res.headers['content-range'], 'bytes 1-1/9'))
.expect((res) => t.equal(res.headers['content-length'], '1', 'should content-length must be as same as maxChunkSize'))
.expect(206, '2', (err) => t.error(err))
})
Expand All @@ -68,8 +68,8 @@ test('send(file, options)', function (t) {
request(createServer({ acceptRanges: true, maxChunkSize: 1, root: fixtures }))
.get('/nums.txt')
.set('Range', 'bytes=1-3')
.expect(shouldHaveHeader('Accept-Ranges', t))
.expect(shouldHaveHeader('Content-Range', t))
.expect((res) => t.equal(res.headers['accept-ranges'], 'bytes'))
.expect((res) => t.equal(res.headers['content-range'], 'bytes 1-1/9'))
.expect((res) => t.equal(res.headers['content-length'], '1', 'should content-length must be as same as maxChunkSize'))
.expect(206, '2', (err) => t.error(err))
})
Expand All @@ -79,9 +79,9 @@ test('send(file, options)', function (t) {

request(createServer({ acceptRanges: true, maxChunkSize: 4, root: fixtures }))
.get('/nums.txt')
.set('Range', 'bytes=1-2,3-5')
.expect(shouldHaveHeader('Content-Range', t))
.expect(shouldHaveHeader('Accept-Ranges', t))
.set('Range', 'bytes=1-2,3-6')
.expect((res) => t.equal(res.headers['accept-ranges'], 'bytes'))
.expect((res) => t.equal(res.headers['content-range'], 'bytes 1-4/9'))
.expect((res) => t.equal(res.headers['content-length'], '4', 'should content-length must be as same as maxChunkSize'))
.expect(206, '2345', (err) => t.error(err))
})
Expand Down

0 comments on commit 027649c

Please sign in to comment.