// Settings Tests
// ==============

@include test-module('General Settings') {
  @include test('susy-defaults') {
    $original-defaults: $susy-defaults;

    $test: map-get($susy-defaults, test);
    @include assert-false($test,
      'Assert that there is no "test" default.');

    @include susy-defaults((test: hello world));

    $test: map-get($susy-defaults, test);
    @include assert-true($test,
      'Assert that we have added a "test" default.');

    $susy-defaults: $original-defaults !global;
  }

  // [mixin] susy-set
  // ----------------

  @include test('[mixin] susy-set') {
    $key: columns;
    $original: susy-get($key);
    $new: $original + 3;

    @include susy-set($key, $new);

    $test: susy-get($key);
    @include assert-equal($test, $new,
      'Changes the global value for a setting.');

    @include original-grid;
  }

  // [function] susy-get
  // -------------------

  @include test('[function] susy-get') {
    $grid: 960px 4 1/4 right border-box float fluid before show-columns rtl;
    $pre: parse-grid($grid);

    $a: susy-get(box-sizing, $grid);
    $b: susy-get(box-sizing, $pre);

    // parsing
    @include assert-equal($a, $b,
      'susy-get should be the same whether pre-parsed or not');

    // simple get
    @include assert-equal($a, border-box,
      'Returns local grid setting when available.');

    // default
    $grid: (columns: 12);
    $test: susy-get(gutters, $grid);
    $expect: map-get($susy-defaults, gutters);
    @include assert-equal($test, $expect,
      'Returns global default grid setting, when local is missing.');

    // null setting
    $grid: (gutters: null);
    $test: susy-get(gutters, $grid);
    $expect: null;
    @include assert-equal($test, $expect,
      'Returns null gutter setting without falling back on default.');

    // deep get
    $grid: (
      columns: 12,
      debug: (
        output: background,
        color: red,
      ),
    );
    $test: susy-get(debug color, $grid);
    $expect: red;
    @include assert-equal($test, $expect,
      'Returns deep grid setting when available.');

    $test: susy-get(turtle monkey dove, $grid);
    $expect: null;
    @include assert-equal($test, $expect,
      'Returns null when deep grid setting is not available.');
  }
}
