diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-07-07 22:17:34 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-07-07 22:17:34 +0100 |
| commit | a080fc59a3fca08bdc6e23a2eeae440f5c7047b3 (patch) | |
| tree | 3d56033c294c617eb7de6b693750efb70a81dd4f /test/unzip.tests.js | |
| parent | 28a0e40b645c051d91626ca90959e847b061c8da (diff) | |
Use exports for all tests
Diffstat (limited to 'test/unzip.tests.js')
| -rw-r--r-- | test/unzip.tests.js | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/test/unzip.tests.js b/test/unzip.tests.js index 994fb68..4e1bd61 100644 --- a/test/unzip.tests.js +++ b/test/unzip.tests.js @@ -2,39 +2,37 @@ var fs = require("fs"); var assert = require("assert"); var path = require("path"); -var test = require("./testing").test; +var test = require("./test")(module); var unzip = require("../lib/unzip"); var promises = require("../lib/promises"); -describe("unzip", function() { - test("unzip fails if given empty object", function() { - return unzip.openZip({}).then(function() { - assert.ok(false, "Expected failure"); - }, function(error) { - assert.equal("Could not find file in options", error.message); - }); +test("unzip fails if given empty object", function() { + return unzip.openZip({}).then(function() { + assert.ok(false, "Expected failure"); + }, function(error) { + assert.equal("Could not find file in options", error.message); + }); +}); + +test("unzip can open local zip file", function() { + var zipPath = path.join(__dirname, "test-data/hello.zip"); + return unzip.openZip({path: zipPath}).then(function(zipFile) { + return zipFile.read("hello", "utf8"); + }).then(function(contents) { + assert.equal(contents, "Hello world\n"); }); - - test("unzip can open local zip file", function() { - var zipPath = path.join(__dirname, "test-data/hello.zip"); - return unzip.openZip({path: zipPath}).then(function(zipFile) { +}); + +test('unzip can open Buffer', function() { + var zipPath = path.join(__dirname, "test-data/hello.zip"); + return promises.nfcall(fs.readFile, zipPath) + .then(function(buffer) { + return unzip.openZip({buffer: buffer}); + }) + .then(function(zipFile) { return zipFile.read("hello", "utf8"); - }).then(function(contents) { + }) + .then(function(contents) { assert.equal(contents, "Hello world\n"); }); - }); - - test('unzip can open Buffer', function() { - var zipPath = path.join(__dirname, "test-data/hello.zip"); - return promises.nfcall(fs.readFile, zipPath) - .then(function(buffer) { - return unzip.openZip({buffer: buffer}); - }) - .then(function(zipFile) { - return zipFile.read("hello", "utf8"); - }) - .then(function(contents) { - assert.equal(contents, "Hello world\n"); - }); - }); }); |
