-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.js
52 lines (45 loc) · 1.39 KB
/
test.js
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
48
49
50
51
52
"use strict";
const fs = require("fs");
const path = require("path");
const bufferEqual = require("buffer-equal");
const createCollage = require("./index");
require("chai")
.use(require("chai-as-promised"))
.should();
// Test a variety of source types - file name, buffer, uri.
const sources = [
"./img/src1.jpg",
"img/src2.jpg",
path.join(__dirname, "img/src3.jpg"),
fs.readFileSync("img/src4.jpg"),
"http://github.com/classdojo/photo-collage/blob/master/img/src5.jpg?raw=true",
"https://github.com/classdojo/photo-collage/blob/master/img/src6.jpg?raw=true",
];
it("2x3 collage with no spacing matches reference", () => {
const options = {
sources: sources,
width: 3,
height: 2,
imageWidth: 350,
imageHeight: 250,
};
return createCollage(options)
.then((canvas) => canvas.toBuffer())
.then((buffer) => bufferEqual(buffer, fs.readFileSync("./img/result_no_spacing.png")))
.should.eventually.equal(true);
});
it("2x3 collage with spacing matches reference", () => {
const options = {
sources: sources,
width: 3,
height: 2,
imageWidth: 350,
imageHeight: 250,
backgroundColor: "#f00",
spacing: 2,
};
return createCollage(options)
.then((canvas) => canvas.toBuffer())
.then((buffer) => bufferEqual(buffer, fs.readFileSync("./img/result_with_spacing.png")))
.should.eventually.equal(true);
});