-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathzipper-spec.js
More file actions
47 lines (39 loc) · 1.45 KB
/
zipper-spec.js
File metadata and controls
47 lines (39 loc) · 1.45 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
42
43
44
45
46
47
// Using data.js
describe("Zipper", function() {
var zip = Zipper.zip;
beforeEach(function() {
spyOn(zip, "generateAsync").and.returnValue(new Promise( function() {} ));
});
it("adds files to the zip", function() {
spyOn(zip, "file");
Zipper.createZip(Downloader);
expect(zip.file).toHaveBeenCalled();
});
it("adds the right amount of files", function() {
spyOn(zip, "file");
Zipper.createZip(Downloader);
expect(zip.file.calls.count()).toBe(4);
});
it("gets the files names right", function() {
spyOn(zip, "file");
spyOn(Downloader, "getFile").and.returnValue("irrelevant");
Zipper.createZip(Downloader);
expect(zip.file).toHaveBeenCalledWith("index.html", "irrelevant", {binary: true});
expect(zip.file).toHaveBeenCalledWith("script.js", "irrelevant", {binary: true});
});
it("tells the downloader to download the files", function() {
spyOn(Downloader, "getFile");
Zipper.createZip(Downloader);
expect(Downloader.getFile).toHaveBeenCalled();
});
it("calls the downloader with the right urls", function() {
spyOn(Downloader, "getFile");
Zipper.createZip(Downloader);
expect(Downloader.getFile).toHaveBeenCalledWith("/js/lesson3/files/index.html");
expect(Downloader.getFile).toHaveBeenCalledWith("/js/lesson3/files/script.js");
});
it("generates a zip file", function() {
Zipper.createZip(Downloader);
expect(zip.generateAsync).toHaveBeenCalled();
});
});