// Margin Syntax Tests
// ===================

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

  // pre
  // ---

  @include output-test('pre') {
    // wide
    @include assert-setup('wide', $grid: 7 .5 before) {
      .spacer { @include span(first 1 wide); }
      .test, .expect { @include span(3); }
    }
    @include assert-output(
      'Items should have 2-columns (wide) margin before.'
    ) {
      .test { @include pre(2); }
      .expect { margin-left: 30%; }
    }

    // split
    @include assert-setup('split', $grid: 8 .25 split) {
      .test, .expect { @include span(4); }
    }
    @include assert-output(
      'Items should have 2-columns margin before, including split gutter.'
    ) {
      .test { @include pre(2); }
      .expect { margin-left: 26.25%; }
    }

    @include assert-setup('split', $grid: 10 0 split) {
      .test, .expect { @include span(4); }
    }
    @include assert-output(
      'Pre works with split 0 gutters.'
    ) {
      .test { @include pre(2); }
      .expect { margin-left: 20%; }
    }

    // wider
    @include assert-setup('wider', $grid: 7 .5 before) {
      .spacer { @include span(first 1); }
      .test, .expect { @include span(3); }
    }
    @include assert-output(
      'Items should have 2-columns (wider) margin before.'
    ) {
      .test { @include pre(2 wider); }
      .expect { margin-left: 35%; }
    }
  }

  // post
  // ----

  @include output-test('post') {
    // wide
    @include assert-setup('wide', $grid: (1 2 3 2 1) .25 after);
    @include assert-output(
      'Items should have 2-columns (wide) margin after.'
    ) {
      .test { @include post(last 2); }
      .expect { margin-right: 35%; }
    }

    // split
    @include assert-setup('split', $grid: (1 2 3 3) .25 split) {
      .test, .expect { @include gutters(); }
    }
    @include assert-output(
      'Items should have 2-columns margin after, including split gutter.'
    ) {
      .test { @include post(last 1); }
      .expect { margin-right: 33.75%; }
    }

    // wider
    @include assert-setup('wider', $grid: (1 2 3 2 1) .25 after) {
      .spacer {
        @include span(1 at 4);
        height: 1rem;
      }
      .test, .expect { @include span(first 2); }
    }
    @include assert-output(
      'Items should have 1-column (wide-2) margin after.'
    ) {
      .test { @include post(1 at 3 wider); }
      .expect { margin-right: 35%; }
    }
  }

  // push
  // ----

  @include output-test('push') {
    @include assert-setup($grid: 8 .25 split) {
      .test, .expect { @include span(4); }
    }
    @include assert-output(
      'Items should have 2-columns margin before.'
    ) {
      .test { @include push(first 2); }
      .expect { margin-left: 26.25%; }
    }
  }

  // pull
  // ----

  @include output-test('pull') {
    // narrow
    @include assert-setup('narrow', $grid: (1 2 3 2 1) .25 before) {
      .spacer { @include span(first 2); }
      .test, .expect { @include span(3 at 2); }
    }
    @include assert-output(
      'Items should pull 1-column, overlapping the spacer.'
    ) {
      .test { @include pull(1 at 2 narrow); }
      .expect { margin-left: -20%; }
    }

    // split
    @include assert-setup('split', $grid: 8 .25 split) {
      .spacer { @include span(first 2); }
      .test, .expect { @include span(6); }
    }
    @include assert-output(
      'Items should pull 1-column, overlapping the spacer.'
    ) {
      .test { @include pull(1); }
      .expect { margin-left: -11.25%; }
    }

    // wide
    @include assert-setup('wide', $grid: (1 2 3 2 1) .25 before) {
      .spacer { @include span(first 2 wide); }
      .test, .expect { @include span(3 at 2); }
    }
    @include assert-output(
      'Items should pull 1-column, overlapping the spacer.'
    ) {
      .test { @include pull(1 at 2); }
      .expect { margin-left: -22.5%; }
    }

    // wider
    @include assert-setup('wider', $grid: (1 2 3 2 1) .25 before) {
      .spacer { @include span(first 2 wide); }
      .test, .expect { @include span(3 at 2 wider); }
    }
    @include assert-output(
      'Items should pull 1-column, overlapping the spacer.'
    ) {
      .test { @include pull(1 at 2 wider); }
      .expect { margin-left: -25%; }
    }
  }

  // squish
  // ------

  @include output-test('squish') {
    // simple
    @include assert-setup('simple', $grid: (1 2 3 2 1) .25);
    @include assert-output(
      'Items should have 2-columns margin before and after.'
    ) {
      .test { @include squish(first 2, last 2 inspect); }
      .expect {
        -susy-squish: first 2, last 2 inspect;
        margin-left: 35%;
        margin-right: 35%;
      }
    }

    // split
    @include assert-setup('split', $grid: (1 2 3 2 1) .25 split);
    @include assert-output(
      'Items should have 2-columns margin before and after.'
    ) {
      .test { @include squish(first 2, last 2); }
      .expect {
        margin-left: 35.25%;
        margin-right: 35.25%;
      }
    }

    // nested
    @include assert-setup('nested', $grid: 7 1/5 inside) {
      .nest { @include squish(1); }
    }
    @include assert-output(
      'Items should have 1-column margin before, and 2 after - nested.'
    ) {
      .test { @include squish(1 2 of 5); }
      .expect {
        margin-left: 20%;
        margin-right: 40%;
      }
    }
  }
}
