-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
61 lines (49 loc) · 1.74 KB
/
index.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
53
54
55
56
57
58
59
60
61
var assert = require("assert");
var sqlStamp = require("../../");
var util = require("./../util");
var path = require("path");
var opts = {
prettyErrors: true
};
describe("pretty-errors", function() {
it("throw too-many-args", function(done) {
var results = util.readSync(["./errs/too-many-args.txt"], __dirname);
sqlStamp([__dirname+"/sql/too-many-args.sql"], opts, function(err) {
assert(err);
assert.equal(util.chomp(err.toString()), results["./errs/too-many-args.txt"]);
done();
});
});
it("throw too-few-args", function(done) {
var results = util.readSync(["./errs/too-few-args.txt"], __dirname);
sqlStamp([__dirname+"/sql/too-few-args.sql"], opts, function(err) {
assert(err);
assert.equal(util.chomp(err.toString()), results["./errs/too-few-args.txt"]);
done();
});
});
it("throw no-such-template", function(done) {
var results = util.readSync(["./errs/no-such-template.txt"], __dirname);
var errStr = results["./errs/no-such-template.txt"]
.replace("%filepath%", path.resolve(__dirname+"/sql/no-such-file.sql"));
sqlStamp([__dirname+"/sql/no-such-template.sql"], opts, function(err) {
assert(err);
assert.equal(util.chomp(err.toString()), errStr);
done();
});
});
it("throw missing-key", function(done) {
var results = util.readSync(["./errs/missing-key.txt"], __dirname);
sqlStamp([__dirname+"/sql/missing-key.sql"], opts, function(err, tmpl) {
var thrownErr;
try {
tmpl(__dirname+"/sql/missing-key.sql", {});
} catch(err) {
thrownErr = err;
}
assert(thrownErr);
assert.equal(util.chomp(thrownErr.toString()), results["./errs/missing-key.txt"]);
done();
});
});
});