Guest User

Untitled

a guest
May 26th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. it('it serves json on port 8001', function() {
  2. var ledger = new Ledger();
  3. ledger.service();
  4. ledger.append([{name:'A Thing', value: "A Value"},{horse:'pony',value:'cake'}],function(err,items){
  5. http = require('http');
  6. var google = http.createClient(8001, 'localhost');
  7. var request = google.request('GET', '/',{'host': 'localhost'});
  8. request.addListener('response', function (response) {
  9. response.setEncoding('utf8');
  10. expect(response.statusCode).toEqual(200);
  11. expect(response.headers["content-type"]).toEqual('text/json');
  12. response.addListener('data', function (chunk) {
  13. data = JSON.parse(chunk);
  14. expect(data[0]['name']).toEqual('A Thing');
  15. expect(data[1]['horse']).toEqual('pony');
  16. asyncSpecDone();
  17. });
  18. });
  19. request.end();
  20. });
  21. asyncSpecWait();
  22. });
Add Comment
Please, Sign In to add comment