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

describe("Order", () => {
  it("Campo con orden ascendente +", () => {
    const type = "+";
    const field = "name";
    const order = Order.create({ type, field });
    expect(order.isSuccess).toBeTruthy();
  });

  it("Campo con orden descendente -", () => {
    const type = "-";
    const field = "date";
    const order = Order.create({ type, field });
    expect(order.isSuccess).toBeTruthy();
  });

  it("Error si el campo no indica orden", () => {
    const type = "";
    const field = "id";
    const order = Order.create({ type, field });
    expect(order.isFailure).toBeTruthy();
  });

  it("Error si el campo de orden tiene un valor diferente de + ó -", () => {
    const type = "*";
    const field = "id";
    const order = Order.create({ type, field });
    expect(order.isFailure).toBeTruthy();
  });

  it("Error si no hay valor para el campo (undefined)", () => {
    const type = "-";
    const field = undefined;
    const order = Order.create({ type, field });
    expect(order.isFailure).toBeTruthy();
  });

  it("Error si no hay valor para el campo (null)", () => {
    const type = "-";
    const field = null;
    const order = Order.create({ type, field });
    expect(order.isFailure).toBeTruthy();
  });

  it('Error si no hay valor para el campo ("")', () => {
    const type = "-";
    const field = "";
    const order = Order.create({ type, field });
    expect(order.isFailure).toBeTruthy();
  });
});
