"use strict";

var _vitest = require("vitest");
var _index = _interopRequireDefault(require("../../lib/stream/index.js"));
var _jsonparser = _interopRequireDefault(require("../../lib/standard/json/jsonparser.js"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
(0, _vitest.describe)('JSON Parser Tests', function () {
  (0, _vitest.it)('number accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('123')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('string accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('"123"')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('string and unrecognized item rejected', function () {
    var content = '"123" -'; //'"123" -'
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString(content)).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('string and unrecognized item rejected with correct offset', function () {
    //FIXME #108
    var result;
    try {
      result = _jsonparser["default"].parse(_index["default"].ofString('["123",2,4]'));
      //console.log('Offsets >>', stream.offsets[7])
    } catch (e) {
      console.error(e);
    }
    (0, _vitest.expect)(result.isEos()).toBe(true);

    //FIXME #108: Not ok with Error
    (0, _vitest.expect)(result.offset).toBe(7);
  });
  (0, _vitest.it)('null accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('null')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('true accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('true')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('false accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('false')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('empty array accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('[ ]')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('singleton array accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('[ 123 ]')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('multi element array accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('[ 123 , 234 ]')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('empty object accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('{ }')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('singleton object accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('{ "a" : "v" }')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('multi element object accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('{ "a" : "v", "a" : [] }')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('multi level object accepted', function () {
    (0, _vitest.expect)(_jsonparser["default"].parse(_index["default"].ofString('{ "a" : "v", "b" : {"c":{"d":12} }}')).isAccepted()).toBe(true);
  });
});
//# sourceMappingURL=jsonparser_test.spec.js.map