Browse Source

Mostly working w/ tests

Noah 8 years ago
parent
commit
1abf310df2
2 changed files with 22 additions and 14 deletions
  1. 18 10
      test/frame-test.js
  2. 4 4
      test/server-test.js

+ 18 - 10
test/frame-test.js View File

@@ -10,6 +10,8 @@ require("mkdirp").sync(path.join(__dirname, "tmp", "frames"));
10 10
 
11 11
 var frameDir = path.join(__dirname, "tmp", "frames");
12 12
 
13
+var waveform = [[0, 1, 0], [1, 0.1, 1]];
14
+
13 15
 tape.test("Draw frame", function(test){
14 16
 
15 17
   var options = {
@@ -18,8 +20,7 @@ tape.test("Draw frame", function(test){
18 20
     backgroundColor: "#f00",
19 21
     foregroundColor: "#fff",
20 22
     waveTop: 340,
21
-    waveBottom: 380,
22
-    waveform: [[0, 1, 0], [1, 0.1, 1]]
23
+    waveBottom: 380
23 24
   };
24 25
 
25 26
   initializeCanvas(options, function(err, renderer){
@@ -28,7 +29,10 @@ tape.test("Draw frame", function(test){
28 29
 
29 30
     drawFrames(renderer, {
30 31
       numFrames: 2,
31
-      frameDir: frameDir
32
+      frameDir: frameDir,
33
+      width: options.width,
34
+      height: options.height,
35
+      waveform: waveform
32 36
     }, function(err){
33 37
       test.error(err);
34 38
       checkFrame(test, options);
@@ -44,8 +48,7 @@ tape.test("Default colors", function(test){
44 48
     width: 1280,
45 49
     height: 720,
46 50
     waveTop: 340,
47
-    waveBottom: 380,
48
-    waveform: [[0, 1, 0], [1, 0.1, 1]]
51
+    waveBottom: 380
49 52
   };
50 53
 
51 54
   initializeCanvas(options, function(err, renderer){
@@ -54,7 +57,10 @@ tape.test("Default colors", function(test){
54 57
 
55 58
     drawFrames(renderer, {
56 59
       numFrames: 2,
57
-      frameDir: frameDir
60
+      frameDir: frameDir,
61
+      width: options.width,
62
+      height: options.height,
63
+      waveform: waveform
58 64
     }, function(err){
59 65
       test.error(err);
60 66
       checkFrame(test, options);
@@ -69,11 +75,10 @@ tape.test("Square frame", function(test){
69 75
   var options = {
70 76
     width: 720,
71 77
     height: 720,
72
-    backgroundColor: "#fc0",
78
+    backgroundColor: "#f00",
73 79
     foregroundColor: "#fff",
74 80
     waveTop: 340,
75
-    waveBottom: 380,
76
-    waveform: [[0, 1, 0], [1, 0.1, 1]]
81
+    waveBottom: 380
77 82
   };
78 83
 
79 84
   initializeCanvas(options, function(err, renderer){
@@ -82,7 +87,10 @@ tape.test("Square frame", function(test){
82 87
 
83 88
     drawFrames(renderer, {
84 89
       numFrames: 2,
85
-      frameDir: frameDir
90
+      frameDir: frameDir,
91
+      width: options.width,
92
+      height: options.height,
93
+      waveform: waveform
86 94
     }, function(err){
87 95
       test.error(err);
88 96
       checkFrame(test, options);

+ 4 - 4
test/server-test.js View File

@@ -84,7 +84,7 @@ tape("Max size", function(test) {
84 84
   request(server)
85 85
     .post("/submit/")
86 86
     .attach("audio", longSample)
87
-    .field("settings", "{}")
87
+    .field("theme", "{}")
88 88
     .expect(500)
89 89
     .end(function(err, res){
90 90
       test.assert(res.text.match(/uploads are limited/i));
@@ -98,7 +98,7 @@ tape("Missing file", function(test) {
98 98
   request(server)
99 99
     .post("/submit/")
100 100
     .type("json")
101
-    .field("settings", "{}")
101
+    .field("theme", "{}")
102 102
     .expect(500)
103 103
     .end(function(err, res){
104 104
       test.assert(res.text.match(/audio/i));
@@ -112,7 +112,7 @@ tape("Broken settings", function(test) {
112 112
   request(server)
113 113
     .post("/submit/")
114 114
     .type("multipart/form-data")
115
-    .field("settings", "a")
115
+    .field("theme", "a")
116 116
     .expect(500)
117 117
     .end(function(err, res){
118 118
       test.assert(res.text.match(/settings/i));
@@ -128,7 +128,7 @@ tape("Successful submission", function(test) {
128 128
   request(server)
129 129
     .post("/submit/")
130 130
     .attach("audio", shortSample)
131
-    .field("settings", JSON.stringify({ test: true }))
131
+    .field("theme", JSON.stringify({ test: true }))
132 132
     .expect(200)
133 133
     .end(function(err, res){
134 134