Noah hace 8 años
padre
commit
01ae29f9b0
Se han modificado 2 ficheros con 44 adiciones y 3 borrados
  1. 2 2
      server/fonts.js
  2. 42 1
      test/server-test.js

+ 2 - 2
server/fonts.js Ver fichero

@@ -1,4 +1,4 @@
1
-var fonts = require("../lib/settings/").fonts;
1
+var fonts = require("../lib/settings/").fonts || [];
2 2
 
3 3
 var bySlug = {};
4 4
 
@@ -29,7 +29,7 @@ function sendFont(req, res) {
29 29
     return res.sendFile(font.file);
30 30
   }
31 31
 
32
-  res.status(500).send("Cannot GET " + req.baseUrl);
32
+  res.status(404).send("Cannot GET " + req.baseUrl);
33 33
 
34 34
 }
35 35
 

+ 42 - 1
test/server-test.js Ver fichero

@@ -4,11 +4,14 @@ var tape = require("tape"),
4 4
     queue = require("d3").queue,
5 5
     request = require("supertest");
6 6
 
7
+var fonts = require("../lib/settings/").fonts;
8
+
7 9
 var serverSettings = require("./patch-settings")({
8 10
   workingDirectory: path.join(__dirname, "tmp", "working"),
9 11
   maxUploadSize: 100000,
10 12
   storagePath: path.join(__dirname, "tmp", "storage"),
11
-  worker: true
13
+  worker: true,
14
+  fonts: fonts
12 15
 });
13 16
 
14 17
 var server = require("../server");
@@ -66,6 +69,44 @@ tape("404 2", function(test) {
66 69
 
67 70
 });
68 71
 
72
+tape("404 3", function(test) {
73
+
74
+  request(server)
75
+    .get("/fonts/something")
76
+    .expect(404)
77
+    .end(function(err, res){
78
+      test.error(err);
79
+      test.end();
80
+    });
81
+
82
+});
83
+
84
+tape("Font stylesheet", function(test) {
85
+
86
+  request(server)
87
+    .get("/fonts/fonts.css")
88
+    .expect(200)
89
+    .expect("Content-Type", /css/)
90
+    .end(function(err, res){
91
+      test.error(err);
92
+      test.end();
93
+    });
94
+
95
+});
96
+
97
+tape("Font file", function(test) {
98
+
99
+  request(server)
100
+    .get("/fonts/custom-0.ttf")
101
+    .expect(200)
102
+    .expect("Content-Type", /ttf/)
103
+    .end(function(err, res){
104
+      test.error(err);
105
+      test.end();
106
+    });
107
+
108
+});
109
+
69 110
 tape("Server static background", function(test) {
70 111
 
71 112
   request(server)