-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodezip_spec.js
More file actions
41 lines (35 loc) · 1.36 KB
/
Copy pathnodezip_spec.js
File metadata and controls
41 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
describe('nodezip', function() {
beforeEach(function() {
this.nodezip = require('..')();
});
describe('when initialized', function() {
it('should load JSZip in this.nodezip', function() {
expect(this.nodezip.options).not.toBeNull();
});
it('should declare JSZip', function() {
expect(JSZip).not.toBeNull();
});
});
describe('when archiving a dummy file', function() {
beforeEach(function() {
this.fs = require("fs");
this.dummyFile = this.nodezip.file('test.file', 'hello there');
this.dummyFileData = this.dummyFile.generate({base64:false,compression:'DEFLATE'});
});
it('should contain valid data', function() {
expect(this.dummyFileData).not.toBeNull();
expect(this.dummyFileData).toMatch(/^PK/);
expect(this.dummyFileData).toMatch(/test.file/);
});
it('should be able to write file', function() {
this.fs.writeFileSync('test.zip', this.dummyFileData, 'binary');
expect(this.fs.lstatSync('test.zip')).not.toBeNull()
});
it('should be able to deflate file', function() {
this.dummyFileData = this.fs.readFileSync('test.zip', 'binary');
this.dummyFile = new JSZip(this.dummyFileData, {base64: false, checkCRC32: true});
expect(this.dummyFile.files['test.file'].asText()).toEqual("hello there");
this.fs.unlink('test.zip');
});
});
});