True 8.0.0

Testing Return Values

@mixin assert-true()

aliased as is-truthy()

Assert that a parameter is truthy.

  • Empty lists and strings are excluded from default Sass truthyness. Assertions are used inside the test() mixin

Parameters

$assert: (*)

Asserted value to test

$description: null (string)

Description of the assertion being tested. A null of false value generates a default description.

Examples

scss
@include true.test('Non-empty strings are truthy') {
  @include true.assert-true(
    'Hello World',
    'You can optionally describe the assertion...');
}
css compiled
@charset "UTF-8";
/* Test: Non-empty strings are truthy */
/*   ✔ [assert-true] You can optionally describe the assertion... */
/*  */
scss
@include true.it('Non-empty strings are truthy') {
  @include true.is-truthy(
    'Hello World',
    'You can optionally describe the assertion...');
}
css compiled
@charset "UTF-8";
/* Test: Non-empty strings are truthy */
/*   ✔ [assert-true] You can optionally describe the assertion... */
/*  */

Requires

@function is-truthy() [private]

Used By

@mixin is-truthy()

@mixin assert-false()

aliased as is-falsy()

Assert that a parameter is falsey.

  • Empty lists and strings are added to default Sass falseyness. to define the expected results of the test.

Parameters

$assert: (*)

Asserted value to test

$description: null (string)

Description of the assertion being tested. A null of false value generates a default description.

Example

scss
@include true.test('Empty strings are falsey') {
  @include true.assert-false(
    '',
    'You can optionally describe the assertion...');
}
css compiled
@charset "UTF-8";
/* Test: Empty strings are falsey */
/*   ✔ [assert-false] You can optionally describe the assertion... */
/*  */

Requires

@function is-truthy() [private]

Used By

@mixin is-falsy()

@mixin assert-equal()

aliased as is-equal()

Assert that two parameters are equal Assertions are used inside the test() mixin to define the expected results of the test.

Parameters

$assert: (*)

Asserted value to test

$expected: (*)

Expected match

$description: null (string)

Description of the assertion being tested (a null of false value generates a default description)

$inspect: false (bool)

Optionally compare inspected values (useful for comparing CSS output rather than Sass values)

Example

scss
@use 'sass:math';
@include true.test('Division works as expected in Sass') {
  @include true.assert-equal(
    math.div(8, 2), 4,
    'You can optionally describe the assertion...');
}
css compiled
@charset "UTF-8";
/* Test: Division works as expected in Sass */
/*   ✔ [assert-equal] You can optionally describe the assertion... */
/*  */

Used By

@mixin is-equal()

@mixin assert-unequal()

aliased as not-equal()

Assert that two parameters are unequal Assertions are used inside the test() mixin to define the expected results of the test.

Parameters

$assert: (*)

Asserted value to test

$expected: (*)

Expected mismatch

$description: null (string)

Description of the assertion being tested. A null of false value generates a default description.

$inspect: false (bool)

Optionally compare inspected values (useful for comparing CSS output rather than Sass values)

Example

scss
@include true.test('Strings and numbers are not the same') {
  @include true.assert-unequal(
    1em,
    '1em');
}
css compiled
@charset "UTF-8";
/* Test: Strings and numbers are not the same */
/*   ✔ [assert-unequal] Strings and numbers are not the same */
/*  */

Used By

@mixin not-equal()