Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- fix thread 3 to have the right list of messages

- generate test results for /thread/:id and /thread/:id/full
- export tests for both types of fetch
  • Loading branch information...
commit 978df25e8a5a686c89ec5a7ae06ac3875963109a 1 parent f62cf7e
@rjp authored
Showing with 26 additions and 6 deletions.
  1. +26 −6 tests/03-threads.js
View
32 tests/03-threads.js
@@ -8,23 +8,28 @@ var testdata = require('../testdata.js');
var threads = {
"1": ["m_one", "m_two", "m_ten"],
"2": ["m_three"],
- "3": ["m_four"],
- "4": ["m_five", "m_seven"]
+ "3": ["m_four", "m_seven"],
+ "4": ["m_five"]
};
// convert our thread shortcuts into full message lists
var expected = [];
+var with_body = [];
for (var thread in threads) {
for (var message in threads[thread]) {
var id = threads[thread][message];
if (expected[thread] == undefined) { expected[thread] = []; }
- var o = testdata.json.preload[id];
+ if (with_body[thread] == undefined) { with_body[thread] = []; }
+ var wb = {}; var o = {};
+ var source = testdata.json.preload[id];
+ for (var i in source) { wb[i] = source[i]; o[i] = source[i]; }
delete o['body'];
expected[thread].push(o);
+ with_body[thread].push(wb);
}
};
-function make_test(thread, who, wanted) {
+function make_header_test(thread, who, wanted) {
var e = expected[thread];
return function(test) {
tester[who].get('/thread/'+thread, function(got, code){
@@ -36,10 +41,25 @@ function make_test(thread, who, wanted) {
}
}
+function make_body_test(thread, who, wanted) {
+ var e = with_body[thread];
+ return function(test) {
+ tester[who].get('/thread/'+thread+'/full', function(got, code){
+ test.expect(2);
+ test.equal(code, 200, '200 OK');
+ test.deepEqual(e, got, "FULL "+thread+", "+who);
+ test.done();
+ });
+ }
+}
+
var users = ['rjp','techno','lurker'];
+var threads = [1,2,3,4];
for(var i in users) {
var user = users[i];
- for(var t in [1,2,3,4]) {
- exports['thread-'+user+'-'+t] = make_test(1, user);
+ for(var t in threads) {
+ var th = threads[t];
+ exports['thread-'+user+'-'+th] = make_header_test(th, user);
+ exports['thread-full-'+user+'-'+th] = make_body_test(th, user);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.