Repository navigation
Expand file tree
/
Copy pathserver.utils.js
More file actions
58 lines (52 loc) · 1.85 KB
/
Copy pathserver.utils.js
File metadata and controls
58 lines (52 loc) · 1.85 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
48
49
50
51
52
53
54
55
56
57
58
"use strict";
var utils = require("../../../lib/server/utils");
var Immutable = require("immutable");
var sinon = require("sinon");
describe("Server: Server Utils: ", function () {
var app;
var spy;
before(function () {
spy = sinon.spy();
app = {
use: spy
};
});
afterEach(function () {
spy.reset();
});
describe("The server utils: addBaseDir", function () {
var base;
beforeEach(function () {
base = "app";
});
it("Should add the static middleware", function () {
utils.addBaseDir(app, base, Immutable.Map());
sinon.assert.calledOnce(spy);
});
it("Should add the static middleware with multiple middlewares", function () {
utils.addBaseDir(app, Immutable.List(["app", "dist"]), Immutable.Map());
sinon.assert.calledTwice(spy);
});
it("Should add the static middleware with multiple middlewares", function () {
utils.addBaseDir(app, Immutable.List(["app", "dist", "alt"]), Immutable.Map());
sinon.assert.calledThrice(spy);
});
});
describe("The server utils: addDirectory", function () {
var base;
beforeEach(function () {
base = "app";
});
it("Should add the directory option to the server app", function () {
utils.addDirectory(app, base);
sinon.assert.called(spy);
});
it("Should add the directory option to the server app when array given", function () {
var path = require("path");
var serveSpy = sinon.spy(path, "resolve");
utils.addDirectory(app, Immutable.List([base, "base-2"]));
sinon.assert.calledWithExactly(serveSpy, base);
serveSpy.restore();
});
});
});