// Gutter Syntax
// =============

@include test-module('Gutter Syntax') {

  // gutters [mixin]
  // ---------------

  @include output-test('gutters') {
    @include assert-setup('auto', $grid: 8 .25 split);
    @include assert-output(
      'Item should have 2.5% margin-gutters added before and after'
    ) {
      .test { @include gutters(of 8); }
      .expect {
        margin-left: 1.25%;
        margin-right: 1.25%;
      }
    }

    @include assert-setup('inside-static', $grid: 7 (4em 2em) inside-static);
    @include assert-output(
      'Item should have 1em padding-gutters added before and after'
    ) {
      .test { @include gutters; }
      .expect {
        padding-left: 1em;
        padding-right: 1em;
      }
    }

    @include assert-setup('explicit', $grid: 7 .5 inside);
    @include assert-output(
      'Item should have 5em padding-gutters added before and after'
    ) {
      .test { @include gutters(10em); }
      .expect {
        padding-left: 5em;
        padding-right: 5em;
      }
    }
  }

  // gutter [function]
  // -----------------

  @include test('[function] gutter') {
    // after
    $test: gutter(of 7 .5 after);
    $expect: 5%;
    @include assert-equal($test, $expect,
      'Returns correct outside gutters.');

    // inside
    $test: gutter(8 .25 inside);
    $expect: 1.25%;
    @include assert-equal($test, $expect,
      'Returns correct inside gutters.');
  }

  // get-gutter-width
  // ----------------

  @include test('[function] get-gutter-width') {
    $cols: 1 2 3 2 1;

    // explicit
    $gutter: get-gutter-width(30% of $cols (40px 10px) static);
    $expect: 30%;
    @include assert-equal($gutter, $expect,
      'Returns correct explicit gutter width.');

    // static
    $gutter: get-gutter-width(of $cols (40px 10px) static);
    $expect: 10px;
    @include assert-equal($gutter, $expect,
      'Returns correct static gutter width.');

    // fluid
    $gutter: get-gutter-width(of $cols .25);
    $expect: 2.5%;
    @include assert-equal($gutter, $expect,
      'Returns correct fluid gutter width.');

    // inside
    $gutter: get-gutter-width(of 8 .25 inside);
    $expect: 2.5%;
    @include assert-equal($gutter, $expect,
      'Returns correct inside gutter width.');

    // split
    $gutter: get-gutter-width(of 8 .25 split);
    $expect: 2.5%;
    @include assert-equal($gutter, $expect,
      'Returns correct split gutter width.');

    // no-gutters
    $gutter: get-gutter-width(8 .25 split no-gutters);
    $expect: null;
    @include assert-equal($gutter, $expect,
      'Returns correct split no-gutters width.');

    // null gutters
    $context: (
      columns: 10,
      gutters: null,
    );
    $gutter: get-gutter-width($context after);
    $expect: null;
    @include assert-equal($gutter, $expect,
      'Returns correct null gutters width.');

    // 0 gutters
    $context: (
      columns: 10,
      gutters: 0,
    );
    $gutter: get-gutter-width($context split);
    $expect: null;
    @include assert-equal($gutter, $expect,
      'Returns null width for 0-gutters.');

    // null gutters
    $context: (
      columns: 10,
      gutters: 0,
    );
    $gutter: get-gutter-width(3em $context split);
    $expect: 3em;
    @include assert-equal($gutter, $expect,
      'Returns correct override width for 0 gutters.');
  }

  // get-gutters
  // -----------

  @include test('[function] get-gutters') {
    $cols: 7;
    $guts: .5;

    // override before
    $test: get-gutters(30% of $cols $guts fluid before);
    $expect: (before: 30%, after: null);
    @include assert-equal($test, $expect,
      'Returns correct explicit before gutter.');

    // override after
    $test: get-gutters(2em of $cols $guts fluid after);
    $expect: (before: null, after: 2em);
    @include assert-equal($test, $expect,
      'Returns correct after gutters.');

    // override inside
    $test: get-gutters(30px of $cols $guts fluid inside);
    $expect: (before: 15px, after: 15px);
    @include assert-equal($test, $expect,
      'Split gutters should be divided, even when explicit.');
  }

  // is-inside [function]
  // -------------------

  @include test('[function] is-inside') {
    // after
    $test: is-inside((gutter-position: after));
    $expect: false;
    @include assert-equal($test, $expect,
      'After gutters are not inside.');

    // inside-static
    $test: is-inside(inside-static);
    $expect: true;
    @include assert-equal($test, $expect,
      'Inside-static gutters are inside.');
  }

  // is-split [function]
  // -------------------

  @include test('[function] is-split') {
    // after
    $test: is-split((gutter-position: after));
    $expect: false;
    @include assert-equal($test, $expect,
      'After gutters are not split.');

    // inside
    $test: is-split(inside);
    $expect: true;
    @include assert-equal($test, $expect,
      'Inside gutters are split.');
  }

  // gutter-math [function]
  // ----------------------

  @include test('[function] gutter-math') {
    // after static
    $test: gutter-math((
      math: static,
      gutter-position: after,
    ));
    $expect: static;
    @include assert-equal($test, $expect,
      'Returns static gutters when math is static.');

    // inside-static
    $test: gutter-math((
      math: fluid,
      gutter-position: inside-static,
    ));
    $expect: static;
    @include assert-equal($test, $expect,
      'Returns static gutters when gutter-position inside-static.');
  }

}
