// Row Start & End
// ===============

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

  // break
  // -----

  @include output-test('break') {
    @include assert-setup($grid: 7 .5 inside) {
      .spacer { @include span(2); }
    }
    @include assert-output(
      'breaks should clear preceeding floats'
    ) {
      .test { @include break; }
      .expect { clear: both; }
    }
  }

  // nobreak
  // -------

  @include output-test('nobreak') {
    @include assert-setup($grid: 7 .5 inside) {
      .spacer { @include span(2); }
      .test, .expect { @include break; }
    }
    @include assert-output(
      'Non-breaks should not clear floated elements'
    ) {
      .test { @include nobreak; }
      .expect { clear: none; }
    }
  }

  // full
  // ---

  @include output-test('full') {
    @include assert-setup('split', $grid: 8 .25 split) {
      .spacer { @include span(2); }
    }
    @include assert-output(
      'Full spans clear preceeding floats, and have gutters.'
    ) {
      .test { @include full; }
      .expect {
        @include break;
        @include span(100% - get-gutter-width());
      }
    }

    @include assert-setup('after', $grid: 7 .5 after) {
      .spacer { @include span(2); }
    }
    @include assert-output(
      'Full spans clear preceeding floats, and have gutters.'
    ) {
      .test { @include full; }
      .expect {
        @include break;
        @include span(100% no-gutters);
      }
    }
  }

  // first
  // -----

  @include output-test('first') {
    // before
    @include assert-setup('before', $grid: 7 .5 before) {
      .test, .expect {
        @include span(2);
        clear: left;
      }
    }
    @include assert-output(
      'First items should have left margins removed.'
    ) {
      .test { @include first; }
      .expect { margin-left: 0; }
    }

    // split
    @include assert-setup('split', $grid: 8 .25 split) {
      .test, .expect {
        @include span(2);
        clear: left;
      }
    }
    @include assert-output(
      'Nothing should happen to split first items.'
    ) {
      .test { @include first; }
    }
  }

  // alpha
  // -----

  @include output-test('alpha') {
    @include assert-setup($grid: 7 .5 before) {
      .test, .expect {
        @include span(2);
        clear: left;
      }
    }
    @include assert-output(
      'Alpha items should have left margins removed.'
    ) {
      .test { @include alpha; }
      .expect { margin-left: 0; }
    }
  }

  // last
  // ----

  @include output-test('last') {
    // after
    @include assert-setup('after', $grid: 7 .5 after) {
      .test, .expect {
        @include span(2);
        clear: both;
      }
    }
    @include assert-output(
      'Last items should float right, with right margins removed'
    ) {
      .test { @include last; }
      .expect {
        float: right;
        margin-right: 0;
      }
    }

    // split
    @include assert-setup('split', $grid: 7 .5 split) {
      .test, .expect {
        @include span(2);
        clear: both;
      }
    }
    @include assert-output(
      'Last items should float right.'
    ) {
      .test { @include last; }
      .expect { float: right; }
    }

    // last-flow
    @include assert-setup('last-flow', $grid: (
      columns: 7,
      gutters: .5,
      gutter-position: after,
      last-flow: from
    )) {
      .test, .expect {
        @include span(2);
        clear: both;
      }
    }
    @include assert-output(
      'Last items should not override float if last-flow is "from", with right margins removed'
    ) {
      .test { @include last; }
      .expect {
        margin-right: 0;
      }
    }
  }

  // omega
  // -----

  @include output-test('omega') {
    @include assert-setup($grid: 7 .5 after) {
      .test, .expect {
        @include span(2);
        clear: both;
      }
    }
    @include assert-output(
      'Omega items should float right, with right margins removed'
    ) {
      .test { @include omega; }
      .expect {
        float: right;
        margin-right: 0;
      }
    }
  }

  // get-edge
  // --------

  @include test('[function] get-edge') {
    $test: get-edge(4 of (1 2 3 4));
    $expect: full;
    @include assert-equal($test, $expect,
      'Returns full if span is equal to column-count');

    $test: get-edge(4 of 8);
    $expect: null;
    @include assert-equal($test, $expect,
      'Returns null if no location or edge given');

    $test: get-edge(first 4 of 8);
    $expect: first;
    @include assert-equal($test, $expect,
      'Returns valid edge without changes');

    $test: get-edge(omega 4 of 8);
    $expect: last;
    @include assert-equal($test, $expect,
      'Returns last in place of omega');

    $test: get-edge(4 of 8 at 1);
    $expect: first;
    @include assert-equal($test, $expect,
      'Calculates first based on location when possible');

    $test: get-edge(4 of 8 at 5);
    $expect: last;
    @include assert-equal($test, $expect,
      'Calculates last based on location when possible');
}

  // get-location
  // ------------

  @include test('[function] get-location') {
    $test: get-location(first 4 of 8 at 2);
    $expect: 2;
    @include assert-equal($test, $expect,
      'Returns valid location without changes');

    $test: get-location(first 4 of 8);
    $expect: 1;
    @include assert-equal($test, $expect,
      'Calculates location based on first when possible');

    $test: get-location(last 4 of 8);
    $expect: 5;
    @include assert-equal($test, $expect,
      'Calculates location based on last when possible');

    $test: get-location(last 50% of 8);
    $expect: null;
    @include assert-equal($test, $expect,
      'Return null when location can't be calculated);
  }

}
