diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-16 14:02:03 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-08-16 14:02:03 +0100 |
| commit | 024d8735f21ae0d0e0e82d15b79db3ceac027d16 (patch) | |
| tree | 55476f8581b9774436d25f6cc97bfa9d93ad9ef8 | |
| parent | 18459a297526a9067e7994ffff939a31d42bbc1d (diff) | |
Add test for writing to zip files
| -rw-r--r-- | tests/zipfile.tests.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/zipfile.tests.js b/tests/zipfile.tests.js new file mode 100644 index 0000000..1a0ab99 --- /dev/null +++ b/tests/zipfile.tests.js @@ -0,0 +1,26 @@ +var assert = require("assert"); + +var JSZip = require("jszip"); + +var test = require("./testing").test; +var zipfile = require("../lib/zipfile"); + +describe("zipfile", function() { + test('file in zip can be read after being written', function() { + var zip = emptyZipFile(); + assert(!zip.exists("song/title")); + + zip.write("song/title", "Dark Blue"); + + assert(zip.exists("song/title")); + return zip.read("song/title", "utf8").then(function(contents) { + assert.equal(contents, "Dark Blue"); + }); + }); +}); + +function emptyZipFile() { + var zip = new JSZip(); + var buffer = zip.generate({type: "arraybuffer"}); + return zipfile.openArrayBuffer(buffer); +} |
