"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _index = _interopRequireDefault(require("../../../lib/stream/index"));
var _jsonparser = _interopRequireDefault(require("../../../lib/standard/json/jsonparser"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/
var _default = exports["default"] = {
  setUp: function setUp(done) {
    done();
  },
  'number accepted': function number_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('123')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'string accepted': function string_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('"123"')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'string and unrecognized item rejected': function string_and_unrecognized_item_rejected(test) {
    test.expect(1);
    // tests here
    var content = '"123" -'; //'"123" -'
    test.equal(_jsonparser["default"].parse(_index["default"].ofString(content)).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'string and unrecognized item rejected with correct offset': function string_and_unrecognized_item_rejected_with_correct_offset(test) {
    //FIXME #108
    // tests here
    try {
      var result = _jsonparser["default"].parse(_index["default"].ofString('["123",2,4]'));
      //console.log('Offsets >>', stream.offsets[7])
    } catch (e) {
      console.error(e);
    }
    test.ok(result.isEos(), 'should be consumed.');

    //FIXME #108: Not ok with Error
    test.equal(result.offset, 7, 'should be 7.');
    test.done();
  },
  'null accepted': function null_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('null')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'true accepted': function true_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('true')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'false accepted': function false_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('false')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'empty array accepted': function empty_array_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('[ ]')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'singleton array accepted': function singleton_array_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('[ 123 ]')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'multi element array accepted': function multi_element_array_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('[ 123 , 234 ]')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'empty object accepted': function empty_object_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('{ }')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'singleton object accepted': function singleton_object_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('{ "a" : "v" }')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'multi element object accepted': function multi_element_object_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('{ "a" : "v", "a" : [] }')).isAccepted(), 'should be accepted.');
    test.done();
  },
  'multi level object accepted': function multi_level_object_accepted(test) {
    test.expect(1);
    // tests here
    test.ok(_jsonparser["default"].parse(_index["default"].ofString('{ "a" : "v", "b" : {"c":{"d":12} }}')).isAccepted(), 'should be accepted.');
    test.done();
  }
};
//# sourceMappingURL=jsonparser_test.js.map