"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var import_proxy = __toESM(require("proxy-polyfill/src/proxy"));
var import_index = __toESM(require("./index"));
describe("themeReader - base specs", () => {
  beforeAll(() => {
    global.Proxy = (0, import_proxy.default)();
  });
  it("should return a function", () => {
    expect(import_index.default).toBeInstanceOf(Function);
  });
  it("should return undefined if key does not exist on the theme", () => {
    expect(typeof import_index.default.colors.randomValue).toBe("undefined");
    expect(typeof import_index.default.randomValue).toBe("undefined");
  });
  it("should have theme.yoga as the base path", () => {
    const yoga = "wow cool theme, such tokens";
    const obj = { theme: { yoga } };
    expect((0, import_index.default)(obj)).toBe(yoga);
  });
  it("should be able to get fields with keys", () => {
    const value = "deep!";
    const obj = {
      theme: {
        yoga: {
          breakpoints: {
            xs: {
              margin: value
            }
          }
        }
      }
    };
    expect(import_index.default.breakpoints.xs.margin(obj)).toBe(value);
  });
  it("should be able to get fields with array position", () => {
    const array = ["nice", "array", "bro"];
    const obj = {
      theme: {
        yoga: {
          borders: array
        }
      }
    };
    array.forEach((val, i) => {
      expect(import_index.default.borders[i](obj)).toBe(val);
    });
  });
  it("should be destructible", () => {
    const baseFontSizeValue = "nice size";
    const primaryValue = "very primary";
    const lgValue = "much large";
    const obj = {
      theme: {
        yoga: {
          baseFontSize: baseFontSizeValue,
          colors: {
            primary: primaryValue
          },
          breakpoints: {
            lg: lgValue
          }
        }
      }
    };
    const {
      baseFontSize,
      colors: { primary },
      breakpoints
    } = import_index.default;
    expect(primary(obj)).toBe(primaryValue);
    expect(breakpoints.lg(obj)).toBe(lgValue);
    expect(baseFontSize(obj)).toBe(baseFontSizeValue);
  });
});
