// Sass Utilities
// ==============


// Get Function
// ------------
@include describe('Get Function [function]') {
  $test: _ac-scale-get-function('times');

  @include it('Returns a function or function-name') {
    @include assert-equal(
      $test,
      if(function-exists('get-function'), get-function('times'), 'times')
    );
  }

  @include it('Returned function or name is callable') {
    @include assert-equal(
      call($test, 'root', 2),
      size('root') * 2
    );
  }

  @if function-exists('get-function') {
    @include it('Functions are returned without change') {
      @include assert-equal(
        _ac-scale-get-function('times'),
        get-function('times')
      );
    }
  }
}


// String Replace
// --------------
@include describe('str-replace [function]') {

  @include it('Replacing a sub-string with another string') {
    @include assert-equal(
      _ac-str-replace('hello terrible world!', 'terrible', 'beautiful'),
      'hello beautiful world!'
    );
  }

  @include it('Replacing a full string') {
    @include assert-equal(
      _ac-str-replace('hello', 'hello', 'world'),
      'world'
    );
  }

  @include it('Replacing a sub-string with nothing') {
    @include assert-equal(
      _ac-str-replace('hello world', 'hello ', false),
      'world'
    );

    @include assert-equal(
      _ac-str-replace('hello world', 'hello ', null),
      'world'
    );
  }

  @include it('Replacing all instances of a sub-string') {
    @include assert-equal(
      _ac-str-replace('hello world', 'o', '000', true),
      'hell000 w000rld');
  }
}


// Interpolate
// -----------
@include describe('interpolate [function]') {
  @include it('Replace any number of interpolation strings with values') {
    @include assert-equal(
      _ac-interpolate('hello %s%s', 'world', '!'),
      'hello world!'
    );
  }
}
