Skip to content

Commit fca649e

Browse files
committed
test: check index-file (and correct test messages)
1 parent 090334f commit fca649e

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

test/integration/binary.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ describe('node-static (CLI)', function () {
7272
assert.equal(cacheControl, 'max-age=3600', 'should respond with cache-control');
7373
});
7474

75+
it('serving file within directory and indexFile', async function () {
76+
const {response /* , stdout */} = await spawnConditional(binFile, [
77+
'-p', this.port, fixturePath, '--index-file', 'hello.txt'
78+
], timeout - 9000, {
79+
condition: /serving ".*?"/,
80+
action: (/* err, stdout */) => {
81+
return fetch(
82+
`http://localhost:${this.port}/`
83+
);
84+
}
85+
});
86+
87+
const {status} = response;
88+
const contentType = response.headers.get('content-type');
89+
const text = await response.text();
90+
91+
assert.equal(status, 200, 'should respond with 200');
92+
assert.equal(contentType, 'text/plain', 'should respond with text/plain');
93+
assert.equal(text, 'hello world', 'should respond with hello world');
94+
});
95+
7596
it('serving file within directory with headers', async function () {
7697
const {response /* , stdout */} = await spawnConditional(binFile, [
7798
'-p', this.port,

test/integration/node-static-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ describe('node-static', function () {
316316
it('serving custom index file', async function () {
317317
const response = await fetch(this.getTestServer() + '/');
318318
assert.equal(response.status, 200, 'should respond with 200');
319-
assert.equal(await response.text(), 'hello world', 'should respond with empty string');
319+
assert.equal(await response.text(), 'hello world', 'should respond with hello world');
320320
});
321321

322322
it('handling malicious urls', async function () {
@@ -327,7 +327,7 @@ describe('node-static', function () {
327327
it('serving custom index file', async function () {
328328
const response = await fetch(this.getTestServer() + '/');
329329
assert.equal(response.status, 200, 'should respond with 200');
330-
assert.equal(await response.text(), 'hello world', 'should respond with empty string');
330+
assert.equal(await response.text(), 'hello world', 'should respond with hello world');
331331
});
332332
});
333333
describe('default extension', function () {

0 commit comments

Comments
 (0)