// Language Setting Tests
// ======================

@include test-module('Language Settings') {

  // [function] parse-grid
  // ---------------------

  @include test('[function] parse-grid') {
    // map
    $grid: (columns: 12);
    $test: parse-grid($grid);
    $expect: $grid;
    @include compare-maps($test, $expect, 'parse-grid: map');

    // grid #1
    $grid: 960px 9 .25 static before show float right ltr background;
    $test: parse-grid($grid);
    $expect: (
      columns: 9,
      gutters: 0.25,
      container: 960px,
      math: static,
      output: float,
      container-position: right,
      flow: ltr,
      gutter-position: before,
      debug: (
        image: show,
        output: background,
      ),
    );
    @include compare-maps($test, $expect, 'parse-grid: #1');

    // grid #2
    $grid: auto (1 2 3 2 1) (4em 1em) fluid isolate show-columns border-box left rtl after;
    $test: parse-grid($grid);
    $expect: (
      columns: (1 2 3 2 1),
      gutters: 0.25,
      container: auto,
      column-width: 4em,
      math: fluid,
      output: isolate,
      container-position: left,
      flow: rtl,
      gutter-position: after,
      box-sizing: border-box,
      debug: (
        image: show-columns,
      ),
    );
    @include compare-maps($test, $expect, 'parse-grid: #2');

    // grid #3
    $grid: center split content-box hide;
    $test: parse-grid($grid);
    $expect: (
      container-position: center,
      gutter-position: split,
      box-sizing: content-box,
      debug: (
        image: hide,
      ),
    );
    @include compare-maps($test, $expect, 'parse-grid: #3');

    // grid #4
    $grid: (columns: 12, gutters: .25) inside show-baseline;
    $test: parse-grid($grid);
    $expect: (
      columns: 12,
      gutters: .25,
      gutter-position: inside,
      debug: (
        image: show-baseline,
      ),
    );
    @include compare-maps($test, $expect, 'parse-grid: #4');

    // grid #5
    $grid: inside-static;
    $test: parse-grid($grid);
    $expect: (gutter-position: inside-static);
    @include compare-maps($test, $expect, 'parse-grid: #5');
  }


  // [function] parse-span
  // ---------------------

  @include test('[function] parse-span') {
    // Span #1
    $test: first 3 of 12 .25 after isolate fluid ltr wide;
    $test: parse-span($test);
    $expect: (
      span: 3,
      edge: first,
      columns: 12,
      gutters: 0.25,
      output: isolate,
      math: fluid,
      spread: wide,
      flow: ltr,
      gutter-position: after,
    );
    @include compare-maps($test, $expect,
      'parse-span: #1');

    // Span #2
    $test: last 4 of (1 2 3 2 1) (4em 1em) before float static rtl nest;
    $test: parse-span($test);
    $expect: (
      span: 4,
      edge: last,
      columns: (1 2 3 2 1),
      gutters: 0.25,
      column-width: 4em,
      output: float,
      math: static,
      flow: rtl,
      gutter-position: before,
      role: nest,
    );
    @include compare-maps($test, $expect,
      'parse-span: #2');

    // Span #3
    $test: 1 of 3 alpha split (spread: wider, column-width: 40px);
    $test: parse-span($test);
    $expect: (
      span: 1,
      edge: alpha,
      columns: 3,
      column-width: 40px,
      gutter-position: split,
      spread: wider,
    );
    @include compare-maps($test, $expect,
      'parse-span: #3');

    // Span #4
    $test: omega 3 of 7 .5 inside;
    $test: parse-span($test);
    $expect: (
      span: 3,
      edge: omega,
      columns: 7,
      gutters: .5,
      gutter-position: inside,
    );
    @include compare-maps($test, $expect,
      'parse-span: #4');

    // Span #5
    $test: 3 at 2 inside no-gutters break;
    $test: parse-span($test);
    $expect: (
      span: 3,
      location: 2,
      gutter-position: inside,
      gutter-override: no-gutters,
      clear: break,
    );
    @include compare-maps($test, $expect,
      'parse-span: #5');

    // Span #6
    $test: 2 (gutter-override: 5em) nobreak;
    $test: parse-span($test);
    $expect: (
      span: 2,
      gutter-override: 5em,
      clear: nobreak,
    );
    @include compare-maps($test, $expect,
      'parse-span: #6');

    // Span #7
    $test: full of 7 (4em 2em) inside-static;
    $test: parse-span($test);
    $expect: (
      span: full,
      edge: full,
      columns: 7,
      gutters: .5,
      column-width: 4em,
      gutter-position: inside-static,
    );
    @include compare-maps($test, $expect,
      'parse-span: #7');
  }

  // [function] parse-gutters
  // ------------------------

  @include test('[function] parse-gutters') {
    // context only
    $test: parse-gutters(of 7 .5 after);
    $expect: (
      columns: 7,
      gutters: .5,
      gutter-position: after,
    );
    @include compare-maps($test, $expect,
      'context-only');

    // context only (no "of")
    $test: parse-gutters(7 .5 after);
    $expect: (
      columns: 7,
      gutters: .5,
      gutter-position: after,
    );
    @include compare-maps($test, $expect,
      'context-only [no "of"]');

    // explicit only
    $test: parse-gutters(30%);
    $expect: (
      gutter-override: 30%,
    );
    @include compare-maps($test, $expect,
      'explicit-only');

    // explicit
    $test: parse-gutters(30em of 7 .5 after);
    $expect: (
      columns: 7,
      gutters: .5,
      gutter-position: after,
      gutter-override: 30em,
    );
    @include compare-maps($test, $expect,
      'explicit');
  }

}
