//import sass testing utilizing sass-true url: https://www.npmjs.com/package/sass-true
@import "true";
@import "tools.scss";
@import "../settings/settings.scss";

@include describe('Tools') {
  @include describe('colors') {
    @include describe('function: ta-color()') {
      @include it('given correct name and number, return corresponding hex value') {
        @include assert-equal(ta-color($name: 'green', $key: 500), #2fadae);
      }

      @include it('given incorrect name and number, return null') {
        @include assert-equal(ta-color($name: 'green', $key: 800), null);
      }

      @include it('given correct name only, return corresponding branded default') {
        @include assert-equal(ta-color($name: 'purple'), #b0078c);
      }

      @include it('given incorrect name only, return null') {
        @include assert-equal(ta-color($name: 'dfbdfgh'), null);
      }

      @include it('given no name or number, return default ta color') {
        @include assert-equal(ta-color(), #e00000);
      }
    }
  }

  @include describe('helpers') {
    @include describe('function: rem()') {
      @include it('given size in px, return rem value') {
        @include assert-equal(rem(1px), 0.0625rem);
      }

      @include it('given size without units, return rem value') {
        @include assert-equal(rem(1), 0.0625rem);
      }

      @include it('given size and context in px, return rem value') {
        @include assert-equal(rem(1px, 1px), 1rem);
      }

      @include it('given size and context without units, return rem value') {
        @include assert-equal(rem(1, 1), 1rem);
      }
    }

    @include describe('function: em()') {
      @include it('given size in px, return em value') {
        @include assert-equal(em(1px), 0.0625em);
      }

      @include it('given size without units, return em value') {
        @include assert-equal(em(1), 0.0625em);
      }

      @include it('given size and context in px, return em value') {
        @include assert-equal(em(1px, 1px), 1em);
      }

      @include it('given size and context without units, return em value') {
        @include assert-equal(em(1, 1), 1em);
      }
    }

    @include describe('function: px-percent()') {
      @include it('given no target or context, return percentage of grid gap in 1920 breakpoint') {
        @include assert-equal(px-percent(), 0.78125);
      }

      @include it('given target and no context, return percentage of target in 1920 breakpoint') {
        $actual: round(px-percent(2px) * 1000) / 1000;

        @include assert-equal($actual, 0.104);
      }

      @include it('given target and context, return percentage of target in context') {
        @include assert-equal(px-percent(1px, 100px), 1);
      }
    }

    @include describe('function: line-height()') {
      @include it('given no height value, return 1') {
        @include assert-equal(line-height(), 1);
      }

      @include it('given a height value, return the height divided by the default (16)') {
        @include assert-equal(line-height(15), 0.9375);
      }
    }

    @include describe('function: strip-units()') {
      @include it('given a px value, return only the number value') {
        @include assert-equal(strip-units(1px), 1);
      }

      @include it('given an em value, return only the number value') {
        @include assert-equal(strip-units(1em), 1);
      }

      @include it('given a rem value, return only the number value') {
        @include assert-equal(strip-units(1rem), 1);
      }
    }
  }

  @include describe('icons') {
    @include describe('function: ta-icon()') {
      @include it('given correct name, return corresponding icon') {
        @include assert-equal(ta-icon('wrench'), '\e904');
      }

      @include it('given incorrect name, return null') {
        @include assert-equal(ta-icon('sdsdg'), null);
      }

      @include it('given no name, return default icon') {
        @include assert-equal(ta-icon(), '\e97e');
      }
    }
  }

  @include describe('breakpoints') {
    @include describe('function: ta-breakpoint()') {
      @include it('given no input, return null') {
        @include assert-equal(ta-breakpoint(), null);
      }

      @include it('given incorrect input, return null') {
        @include assert-equal(ta-breakpoint('bad'), null);
      }

      @include it('given \'xs\', return 0') {
        @include assert-equal(ta-breakpoint('xs'), 0);
      }

      @include it('given \'sm\', return 600px') {
        @include assert-equal(ta-breakpoint('sm'), 600px);
      }

      @include it('given \'md\', return 960px') {
        @include assert-equal(ta-breakpoint('md'), 960px);
      }

      @include it('given \'lg\', return 1440px') {
        @include assert-equal(ta-breakpoint('lg'), 1440px);
      }

      @include it('given \'xl\', return 1920px') {
        @include assert-equal(ta-breakpoint('xl'), 1920px);
      }
    }

    @include describe('mixin: xs-screen') {
      @include it('Wrap content in min-width:0px and max-width:599 media query for extra-small screens') {
        @include assert {
          @include output {
            @include xs-screen {
              height: 1px;
            }
          }

          @include expect {
            @media (min-width: 0) and (max-width: 599px) {
              height: 1px;
            }
          }
        }
      }
    }

    @include describe('mixin: sm-screen') {
      @include it('Wrap content in min-width:600px and max-width:959 media query for small screens') {
        @include assert {
          @include output {
            @include sm-screen {
              height: 1px;
            }
          }

          @include expect {
            @media (min-width: 600px) and (max-width: 959px) {
              height: 1px;
            }
          }
        }
      }
    }

    @include describe('mixin: md-screen') {
      @include it('Wrap content in min-width:960 and max-width:1439 media query for medium screens') {
        @include assert {
          @include output {
            @include md-screen {
              height: 1px;
            }
          }

          @include expect {
            @media (min-width: 960px) and (max-width: 1439px) {
              height: 1px;
            }
          }
        }
      }
    }

    @include describe('mixin: lg-screen') {
      @include it('Wrap content in min-width:1440px and max-width:1919px media query for large screens') {
        @include assert {
          @include output {
            @include lg-screen {
              height: 1px;
            }
          }

          @include expect {
            @media (min-width: 1440px) and (max-width: 1919px) {
              height: 1px;
            }
          }
        }
      }
    }

    @include describe('mixin: xl-screen') {
      @include it('Wrap content in min-width:1920px media query for extra-large screens') {
        @include assert {
          @include output {
            @include xl-screen {
              height: 1px;
            }
          }

          @include expect {
            @media (min-width: 1920px) {
              height: 1px;
            }
          }
        }
      }
    }
  }
}
