"use strict";

var _react = _interopRequireDefault(require("react"));

var _highlighter = require("../highlighter");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

test('compareArea works', function () {
  expect((0, _highlighter.compareArea)([1, 1], [1, 1])).toEqual(0);
  expect((0, _highlighter.compareArea)([1, 0], [1, 1])).toBeLessThan(0);
  expect((0, _highlighter.compareArea)([1, 1], [1, 0])).toBeGreaterThan(0);
  expect((0, _highlighter.compareArea)([0, 1], [1, 1])).toBeLessThan(0);
  expect((0, _highlighter.compareArea)([1, 1], [0, 1])).toBeGreaterThan(0);
});
test('findAll works', function () {
  expect((0, _highlighter.findAll)('', 'b')).toEqual([]);
  expect((0, _highlighter.findAll)('b', 'b')).toEqual([[0, 1]]);
  expect((0, _highlighter.findAll)('bcb', 'b')).toEqual([[0, 1], [2, 1]]);
  expect((0, _highlighter.findAll)('abc', 'b')).toEqual([[1, 1]]);
  expect((0, _highlighter.findAll)('abb', 'b')).toEqual([[1, 1], [2, 1]]);
});
test('simplifyAreas works', function () {
  expect((0, _highlighter.simplifyAreas)([])).toEqual([]);
  expect((0, _highlighter.simplifyAreas)([[0, 1]])).toEqual([[0, 1]]);
  expect((0, _highlighter.simplifyAreas)([[0, 1], [1, 1]])).toEqual([[0, 2]]);
  expect((0, _highlighter.simplifyAreas)([[0, 2], [1, 3]])).toEqual([[0, 4]]);
  expect((0, _highlighter.simplifyAreas)([[0, 1], [2, 1]])).toEqual([[0, 1], [2, 1]]);
  expect((0, _highlighter.simplifyAreas)([[0, 1], [1, 1], [2, 1]])).toEqual([[0, 3]]);
});
test('makeSpans works', function () {
  expect((0, _highlighter.makeSpans)('', [], 'highlight')).toEqual([]);
  expect((0, _highlighter.makeSpans)('hello world', [[0, 5]], 'highlight')).toEqual([_react.default.createElement("span", {
    key: "0-hello",
    className: "highlight"
  }, "hello"), _react.default.createElement("span", {
    key: "1- world"
  }, " world")]);
  expect((0, _highlighter.makeSpans)('hello beautiful world', [[6, 9]], 'highlight')).toEqual([_react.default.createElement("span", {
    key: "0-hello "
  }, "hello "), _react.default.createElement("span", {
    key: "1-beautiful",
    className: "highlight"
  }, "beautiful"), _react.default.createElement("span", {
    key: "2- world"
  }, " world")]);
  expect((0, _highlighter.makeSpans)('hello beautiful world', [[0, 5], [16, 5]], 'highlight')).toEqual([_react.default.createElement("span", {
    key: "0-hello",
    className: "highlight"
  }, "hello"), _react.default.createElement("span", {
    key: "1- beautiful "
  }, " beautiful "), _react.default.createElement("span", {
    key: "2-world",
    className: "highlight"
  }, "world")]);
});
var highlight = (0, _highlighter.createHighlighter)(function (id) {
  return {
    1: '',
    2: 'hello beautiful world'
  }[id];
}, 'highlight', 1);
test('highlight works', function () {
  expect(highlight(1, '')).toEqual([_react.default.createElement("span", {
    key: "0-"
  }, '')]);
  expect(highlight(2, 'hello world')).toEqual([_react.default.createElement("span", {
    key: "0-hello",
    className: "highlight"
  }, "hello"), _react.default.createElement("span", {
    key: "1- beautiful "
  }, " beautiful "), _react.default.createElement("span", {
    key: "2-world",
    className: "highlight"
  }, "world")]);
});