"use strict";

var _url = require("../url");

describe("Object => URL => Object encoding", function () {
  test("encodeObjectToUrlSearchParams(object) => decodeUrlSearchParams(result) => object", function () {
    var urlObject = {
      layout: "foo",
      groupBy: "bar",
      health: true,
      labels: {
        a: 1,
        b: 0,
        c: -1,
        d: "1",
        e: "0",
        f: "-1"
      },
      foo: "bar",
      arr: ["bar", 1, true]
    };
    var encodedString = (0, _url.encodeObjectToUrlSearchParams)(urlObject);
    var decodedObject = (0, _url.decodeUrlSearchParams)("".concat(encodedString, "&foo=bar"));
    expect(urlObject).toMatchObject(decodedObject);
  });
  test("encodeObjectToUrlSearchParams({}) => decodeUrlSearchParams(result) => {}", function () {
    var urlObject = {};
    var encodedString = (0, _url.encodeObjectToUrlSearchParams)(urlObject);
    var decodedObject = (0, _url.decodeUrlSearchParams)(encodedString);
    expect(urlObject).toMatchObject(decodedObject);
  });
  test("decodeUrlSearchParams('?foo=bar') => { foo: 'bar' }", function () {
    var urlObject = {
      foo: "bar"
    };
    var decodedObject = (0, _url.decodeUrlSearchParams)("?foo=bar");
    expect(urlObject).toMatchObject(decodedObject);
  });
});