<commit_before>// Map Utility Tests
// =================

@use 'sass:color';
@use 'sass:map';
@use 'sass:meta';

@use 'true';
@use '~accoutrement/sass/tools' with (
  $functions: (
    'darken': meta.get-function('darken'),
    'desaturate': meta.get-function('desaturate'),
  )
);

@use '../../../scss/utilities/json-api' as *;
@use '../../../scss/utilities/maps' as *;

$colors-compiled: (
  'brand-blue': #0d7fa5,
  'light-gray': #dedede,
  'gray': #555b5e,
  'black': #3b4042,
);
$darken: (
  'brand-blue': #063646,
  'light-gray': #ababab,
  'gray': #252728,
  'black': #0b0c0c,
);
tools.$sizes: (
  'root': 20px,
  'rhythm': '#root'
    (
      'scale': '_fifth' 1,
      'convert': 'rem',
    )
);

$sizes-compiled: (
  'root': 20px,
  'rhythm': 1.5rem,
);

// Each Value
// ----------
@include true.describe('each-value [function]') {
  @include true.it('returns a map with values run through a given function') {
    @include true.assert-equal(
      each-value($colors-compiled, meta.get-function('darken'), 20%),
      $darken,
      $inspect: true
    );
  }
}

// Map Compile
// -----------
@include true.describe('each-key [function]') {
  @include true.it('returns a map with keys run through a given function') {
    @include true.assert-equal(
      each-key(tools.$sizes, meta.get-function('size', $module: 'tools')),
      $sizes-compiled,
      $inspect: true
    );
  }
}

// Herman Add
// ----------
@include true.describe('add [mixin]') {
  $herman: () !global;
  $empty: ();

  @include true.it('adds a map to the $herman global') {
    @include true.assert-equal($herman, $empty);

    @include add('colors', 'compiled', $colors-compiled);

    $expect: (
      'colors': (
        'compiled': $colors-compiled,
      ),
    );

    @include true.assert-equal($herman, $expect);
  }

  @include true.it('adds to existing data of the type') {
    @include add('colors', 'darken', $darken);

    $existing: map.get($herman, 'colors');
    $new: (
      'compiled': $colors-compiled,
    );
    $expect: (
      'colors': map.merge($existing, $new),
    );

    @include true.assert-equal($herman, $expect);
  }
}<commit_msg>Fix broken tests for utility.add, and test pluralization #344<commit_after>// Map Utility Tests
// =================

@use 'sass:color';
@use 'sass:map';
@use 'sass:meta';

@use 'true';
@use '~accoutrement/sass/tools' with (
  $functions: (
    'darken': meta.get-function('darken'),
    'desaturate': meta.get-function('desaturate'),
  )
);

@use '../../../scss/utilities/json-api' as *;
@use '../../../scss/utilities/maps' as *;

$colors-compiled: (
  'brand-blue': #0d7fa5,
  'light-gray': #dedede,
  'gray': #555b5e,
  'black': #3b4042,
);
$darken: (
  'brand-blue': #063646,
  'light-gray': #ababab,
  'gray': #252728,
  'black': #0b0c0c,
);
tools.$sizes: (
  'root': 20px,
  'rhythm': '#root'
    (
      'scale': '_fifth' 1,
      'convert': 'rem',
    )
);

$sizes-compiled: (
  'root': 20px,
  'rhythm': 1.5rem,
);

// Each Value
// ----------
@include true.describe('each-value [function]') {
  @include true.it('returns a map with values run through a given function') {
    @include true.assert-equal(
      each-value($colors-compiled, meta.get-function('darken'), 20%),
      $darken,
      $inspect: true
    );
  }
}

// Map Compile
// -----------
@include true.describe('each-key [function]') {
  @include true.it('returns a map with keys run through a given function') {
    @include true.assert-equal(
      each-key(tools.$sizes, meta.get-function('size', $module: 'tools')),
      $sizes-compiled,
      $inspect: true
    );
  }
}

// Herman Add
// ----------
@include true.describe('add [mixin]') {
  $herman: () !global;
  $empty: ();

  @include true.it('adds a map to the $herman global') {
    @include true.assert-equal($herman, $empty);

    @include add('colors', 'compiled', $colors-compiled);

    $expect: (
      'colors': (
        'compiled': $colors-compiled,
      ),
    );

    @include true.assert-equal($herman, $expect);
  }

  @include true.it('adds to existing data of the type') {
    $existing: map.get($herman, 'colors');
    $new: (
      'darken': $darken,
    );
    $expect: (
      'colors': map.merge($existing, $new),
    );

    @include add('colors', 'darken', $darken);
    @include true.assert-equal($herman, $expect);
  }

  @include true.it('fixes pluralization mistakes with known data types') {
    $existing: map.get($herman, 'colors');
    $new: (
      'darken-2': $darken,
    );
    $expect: (
      'colors': map.merge($existing, $new),
    );

    @include add('color', 'darken-2', $darken);
    @include true.assert-equal($herman, $expect);
  }
}
{'fraction_non_alphanumeric': 0.22234133790737565, 'fraction_numerical': 0.01650943396226415, 'mean_word_length': 2.8810316139767056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5262340', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1703, 'n_words': 359}