import { OrderCriteria } from "../OrderCriteria";

describe("OrderCriteria", () => {
  it("Cadena con orden ascendente", () => {
    const value = "name";
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
  });

  it("Cadena con orden ascendente +", () => {
    const value = "+name";
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
  });

  it("Cadena con orden descendente -", () => {
    const value = "-date";
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
  });

  it("Criterio vacio si no hay valor para el campo (undefined)", () => {
    const value = undefined;
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
    expect(order.object.isEmpty()).toBeTruthy();
  });

  it("Criterio vacio si no hay valor para el campo (null)", () => {
    const value = null;
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
    expect(order.object.isEmpty()).toBeTruthy();
  });

  it('Criterio vacio si no hay valor para el campo ("")', () => {
    const value = "";
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
    expect(order.object.isEmpty()).toBeTruthy();
  });

  it("Analizar cadena de criterios (+date-)", () => {
    const value = "";
    const order = OrderCriteria.create(value);
    expect(order.isSuccess).toBeTruthy();
    expect(order.object.isEmpty()).toBeTruthy();
  });
});
