You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
696 B

  1. var assert = require('better-assert');
  2. var expect = require('expect.js');
  3. var parsejson = require('./index.js');
  4. describe('my suite', function(){
  5. it('should parse a JSON string', function () {
  6. var jsonString = '{"users" :[{"first_name":"foo", "last_name":"bar"}],' +
  7. '"id" :40,' +
  8. '"cities":["los angeles", "new york", "boston"]}';
  9. var jsonObj = parsejson(jsonString);
  10. expect(jsonObj.users[0].first_name).to.be("foo");
  11. expect(jsonObj.users[0].last_name).to.be("bar");
  12. expect(jsonObj.id).to.be(40);
  13. expect(jsonObj.cities[0]).to.be('los angeles');
  14. expect(jsonObj.cities[1]).to.be('new york');
  15. expect(jsonObj.cities[2]).to.be('boston');
  16. });
  17. });