kopia lustrzana https://github.com/c9/core
convert tests to mocha
rodzic
65e938ee72
commit
82ed6bb688
10
package.json
10
package.json
|
@ -50,17 +50,17 @@
|
|||
"licenses": [],
|
||||
"c9plugins": {
|
||||
"c9.ide.language": "#afda452919",
|
||||
"c9.ide.language.css": "#eab00e0694",
|
||||
"c9.ide.language.css": "#ef8a28943e",
|
||||
"c9.ide.language.generic": "#8a3be4533a",
|
||||
"c9.ide.language.html": "#13321c4eb3",
|
||||
"c9.ide.language.html": "#bbe81afed1",
|
||||
"c9.ide.language.html.diff": "#0d49022da4",
|
||||
"c9.ide.language.javascript": "#8479d0a9c1",
|
||||
"c9.ide.language.javascript.immediate": "#99ed8f4560",
|
||||
"c9.ide.language.javascript.eslint": "#8832423ad1",
|
||||
"c9.ide.language.javascript.tern": "#7aab8b0b6a",
|
||||
"c9.ide.language.javascript.infer": "#ded7df5136",
|
||||
"c9.ide.language.jsonalyzer": "#98626d237b",
|
||||
"c9.ide.collab": "#104ec85dd1",
|
||||
"c9.ide.language.javascript.infer": "#239bfdc0d1",
|
||||
"c9.ide.language.jsonalyzer": "#7261f47b26",
|
||||
"c9.ide.collab": "#c8d81b162c",
|
||||
"c9.ide.local": "#cf624506cc",
|
||||
"c9.ide.find": "#ef82bc4f0d",
|
||||
"c9.ide.find.infiles": "#1b83cf12f1",
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
"use server";
|
||||
"use mocha";
|
||||
|
||||
require("c9/inline-mocha")(module);
|
||||
if (typeof define === "undefined") {
|
||||
require("amd-loader");
|
||||
}
|
||||
|
||||
require("amd-loader");
|
||||
var assert = require("assert");
|
||||
var fs = require("fs");
|
||||
var tmp = require("tmp");
|
||||
|
@ -12,11 +17,10 @@ var download = require("./download");
|
|||
var urlParse = require('url').parse;
|
||||
var execFile = require('child_process').execFile;
|
||||
|
||||
module.exports = {
|
||||
describe(__filename, function(){
|
||||
this.timeout(4000);
|
||||
|
||||
timeout: 4000,
|
||||
|
||||
setUp: function(next) {
|
||||
beforeEach(function(next) {
|
||||
var that = this;
|
||||
var vfs = localfs({root: "/"});
|
||||
download({}, {
|
||||
|
@ -41,80 +45,85 @@ module.exports = {
|
|||
});
|
||||
that.server.listen(8787, "0.0.0.0", next);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function(next) {
|
||||
afterEach(function(next) {
|
||||
this.server.close(next);
|
||||
},
|
||||
});
|
||||
|
||||
"test download": function(next) {
|
||||
tmp.dir({unsafeCleanup: true}, function(err, path) {
|
||||
var filename = path + "/download.tar.gz";
|
||||
var file = fs.createWriteStream(filename);
|
||||
http.get("http://localhost:8787/?download=download.tar.gz", function(res) {
|
||||
assert.equal(res.headers["content-type"], "application/x-gzip");
|
||||
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''download.tar.gz");
|
||||
|
||||
res.pipe(file);
|
||||
|
||||
res.on("end", function() {
|
||||
execFile("tar", ["-zxvf", filename, "c9.vfs.server/download.js"], {cwd: path}, function(err, stdout, stderr) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(
|
||||
fs.readFileSync(__dirname + "/download.js", "utf8"),
|
||||
fs.readFileSync(path + "/c9.vfs.server/download.js", "utf8")
|
||||
);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
describe("download", function() {
|
||||
|
||||
"test download sub directory": function(next) {
|
||||
tmp.dir({unsafeCleanup: true}, function(err, path) {
|
||||
var filename = path + "/download.tar.gz";
|
||||
var file = fs.createWriteStream(filename);
|
||||
http.get("http://localhost:8787/views?download=download.tar.gz", function(res) {
|
||||
res.pipe(file);
|
||||
|
||||
res.on("end", function() {
|
||||
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(
|
||||
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
|
||||
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
|
||||
);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
it("should download", function(next) {
|
||||
tmp.dir({unsafeCleanup: true}, function(err, path) {
|
||||
var filename = path + "/download.tar.gz";
|
||||
var file = fs.createWriteStream(filename);
|
||||
http.get("http://localhost:8787/?download=download.tar.gz", function(res) {
|
||||
assert.equal(res.headers["content-type"], "application/x-gzip");
|
||||
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''download.tar.gz");
|
||||
|
||||
"test download without specifying a name": function(next) {
|
||||
tmp.dir({unsafeCleanup: true}, function(err, path) {
|
||||
var filename = path + "/download.tar.gz";
|
||||
var file = fs.createWriteStream(filename);
|
||||
http.get("http://localhost:8787/views?download", function(res) {
|
||||
assert.equal(res.headers["content-type"], "application/x-gzip");
|
||||
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''views.tar.gz");
|
||||
|
||||
res.pipe(file);
|
||||
|
||||
res.on("end", function() {
|
||||
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(
|
||||
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
|
||||
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
|
||||
);
|
||||
next();
|
||||
res.pipe(file);
|
||||
|
||||
res.on("end", function() {
|
||||
execFile("tar", ["-zxvf", filename, "c9.vfs.server/download.js"], {cwd: path}, function(err, stdout, stderr) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(
|
||||
fs.readFileSync(__dirname + "/download.js", "utf8"),
|
||||
fs.readFileSync(path + "/c9.vfs.server/download.js", "utf8")
|
||||
);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
!module.parent && require("asyncjs").test.testcase(module.exports).exec();
|
||||
|
||||
it("should download sub directory", function(next) {
|
||||
tmp.dir({unsafeCleanup: true}, function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = path + "/download.tar.gz";
|
||||
var file = fs.createWriteStream(filename);
|
||||
http.get("http://localhost:8787/views?download=download.tar.gz", function(res) {
|
||||
res.pipe(file);
|
||||
|
||||
res.on("end", function() {
|
||||
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(
|
||||
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
|
||||
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
|
||||
);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should download without specifying a name", function(next) {
|
||||
tmp.dir({unsafeCleanup: true}, function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = path + "/download.tar.gz";
|
||||
var file = fs.createWriteStream(filename);
|
||||
http.get("http://localhost:8787/views?download", function(res) {
|
||||
assert.equal(res.headers["content-type"], "application/x-gzip");
|
||||
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''views.tar.gz");
|
||||
|
||||
res.pipe(file);
|
||||
|
||||
res.on("end", function() {
|
||||
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(
|
||||
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
|
||||
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
|
||||
);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Ładowanie…
Reference in New Issue