// Functions
// =========

@include test-module("susyone functions") {

  // container-outer-width
  @include test("container-outer-width") {
    @include assert-equal(
      container-outer-width(), 59em,
      "Returns the correct outer width of a default container."
    );
    @include assert-equal(
      container-outer-width(8), 39em,
      "Returns the correct outer width whith specified columns."
    );
    @include assert-equal(
      container-outer-width(12, 80em), 78em,
      "Returns correct outer width when columns and outerwidth is specified."
    );
    $border-box-sizing: true !global;
    @include assert-equal(
      container-outer-width(12, 80%), 80%,
      "Returns correct outer width when columns and outerwidth is specified."
    );
    $border-box-sizing: false !global;
  }

  // get-layout
  @include test("get-layout") {
    @include assert-equal(
      get-layout(30em), 7,
      "Returns correct layout based on min width."
    );
  }

  // format-nth
  @include test("format-nth") {
    @include assert-equal(
      format-nth(3), "nth-child(3)",
      "Returns correct selector for nth-child."
    );
    @include assert-equal(
      format-nth(first), "first-child",
      "Returns correct selector for first-child."
    );
    @include assert-equal(
      format-nth(last), "last-child",
      "Returns correct selector for last-child."
    );
    @include assert-equal(
      format-nth(only), "only-child",
      "Returns correct selector for only child."
    );
  }

  // columns-width
  @include test("columns-width") {
    @include assert-equal(
      columns-width(),
      59em,
      "Returns the full width of a grid based on grid settings."
    );
    @include assert-equal(
      columns-width(24),
      119em,
      "Returns the full width of a grid based on custom param."
    );
  }

  // relative-width
  @include test("relative-width") {
    @include assert-equal(
      relative-width(4em, 24), percentage(4em / 119em),
      "Returns width based on percentage of given context."
    );
  }

  // columns
  @include test("columns") {
    @include assert-equal(
      columns(12, 24, static), 59em,
      "Returns proper layout."
    );
    @include assert-equal(
      columns(12, 12, fluid),
      100%,
      "Returns proper layout."
    );
    @include assert-equal(
      columns(12, 24, fluid),
      percentage(59em / 119em),
      "Returns proper layout."
    );
  }

  // medialayout
  @include test("medialayout") {
    @include assert-equal(
      medialayout(30em 12 60em),
      30em 12 60em false,
      "Works with three arguments. $min: 30em, $cols: 12, $max: 30em ."
    );
    @include assert-equal(
      medialayout(12),
      false 12 false false,
      "Works with one argument for columns."
    );
    @include assert-equal(
      medialayout(12 lt-ie8), false 12 false lt-ie8,
      "Works with columns and ie support."
    );
    @include assert-equal(
      medialayout(60em 12 30em lt-ie9),
      30em 12 60em lt-ie9,
      "Works with four arguments for min-width, columns, max-width and IE fallback."
    );
  }

  // is-default-layout
  @include test("is-default-layout") {
    @include assert-equal(
      is-default-layout(30em 12 60em),
      false,
      "Returns false if $media-layout overrides the default layout."
    );
    @include assert-equal(
      is-default-layout(12),
      true,
      "Returns true if $media-layout matches default coulms."
    );
    @include assert-equal(
      is-default-layout(12 lt-ie8),
      true,
      "Returns true if $media-layout matches default coulms."
    );
    @include assert-equal(
      is-default-layout(60em 12 30em lt-ie9),
      false,
      "Returns false if $media-layout overrides the default layout."
    );
  }

  // split-columns-values
  @include test("split-columns-value") {
    @include assert-equal(
      split-columns-value(12 omega),
      12,
      "Returns just column count when given two arguments."
    );
    @include assert-equal(
      split-columns-value(9),
      9,
      "Returns just column count when given one argument."
    );
    @include assert-equal(
      split-columns-value(24 omega, columns),
      24,
      "Returns column count when spcified."
    );
    @include assert-equal(
      split-columns-value(9 omega, position),
      omega,
      "Returns column position when specified."
    );
  }

  // fix-static-misalignment()
  @include test("fix-static-misalignment") {
    @include assert-equal(
      fix-static-misalignment(),
      magic,
      "Confirm default container is set to magic"
    );
    $container-width: 1200px !global;
    @include assert-equal(
      fix-static-misalignment(static, 12),
      fluid,
      "Confirm custom container-width is accounted for."
    );
    $container-width: false !global;
  }

  // gutter
  @include test("gutter") {
    @include assert-equal(
      gutter(),
      percentage(1 / 59),
      "Return the percentage width of a single gutter in a given 'context'."
    );
    @include assert-equal(
      gutter(24, static),
      1em,
      "Return a fixed width if style is static."
    );
  }

  // Revisit:
  // base-ems();
  // absolute-ems();
  // fix-ems();
}
