forked from dropzone/dropzone
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use express instead for the test server tests specs were slightly modified in that regard
- Loading branch information
1 parent
2432d91
commit a795237
Showing
6 changed files
with
182 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
// A simple test server that serves all files in `test-sites/` and accepts POST | ||
// requests. | ||
|
||
const http = require("http"); | ||
const static = require("node-static"); | ||
// and PUT requests. | ||
const express = require('express'); | ||
const path = require('path'); | ||
|
||
const app = express(); | ||
const port = 8888; | ||
|
||
const staticFiles = new static.Server(`${__dirname}/test-sites/`); | ||
// serve static files from this dir | ||
app.use(express.static(path.join(__dirname, 'test-sites'))); | ||
// middleware to parse incoming requests body | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
// Handle all POST requests | ||
app.post('*', (_, res) => { | ||
// Send a success response | ||
res.json({ success: true }); | ||
}); | ||
|
||
const httpServer = http.createServer((req, res) => { | ||
if (req.method == "GET") { | ||
// Every GET request is simply served as static file. | ||
return staticFiles.serve(req, res); | ||
// Handle all PUT requests | ||
app.put('*', (req, res) => { | ||
// Special handling for URLs that start with `/amazon-multipart-upload` | ||
if (req.path.startsWith('/amazon-multipart-upload')) { | ||
const etag = `"${Math.round(Math.random() * 10000)}"`; | ||
res.set('ETag', etag); | ||
} | ||
|
||
req | ||
.on("data", (chunk) => {}) | ||
.on("end", () => { | ||
const headers = req.url.startsWith("/amazon-multipart-upload") | ||
? { ETag: `"${Math.round(Math.random() * 10000)}"` } | ||
: undefined; | ||
res.writeHead(200, headers); | ||
res.end('{"success": true}'); | ||
}); | ||
// Send a success response | ||
res.json({ success: true }); | ||
}); | ||
|
||
httpServer.listen(port); | ||
|
||
console.log(`Running on http://localhost:${port}`); | ||
app.listen(port, () => { | ||
console.log(`Test server running on http://localhost:${port}`); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
These sites serve as examples, and are tested with Cypress. | ||
|
||
The tests are in `/cypress/integration`. | ||
The tests are in `/cypress/e2e`. |
Oops, something went wrong.