0

我正在尝试测试一段 sass 代码,更确切地说是一个 mixin。这个:

// Mixin: Font Size
//
// For using REM and a fallback
//
// usage:
// @include font-size(1.2);
//
@mixin font-size($sizeValue: 1.6) {
  font-size: ($sizeValue * 10) + px;
  font-size: $sizeValue + rem;
}

我正在使用 [Bootcamp] ( http://thejameskyle.com/bootcamp/#!/wiki/Introduction ) 进行测试。这是我的测试:

@include describe("test block \: mixin font-size") {
  @include it("should expect positive values to be calculated correctly") {
    @include should( expect("@include font-size(1.2);"), to(equal("font-size: 16px;font-size: 1.6rem;")));
  }
}

正如你所看到的,它的语法类似于 Protactor,我知道它写得很好。我也知道 mixin 处理的是:

font-size: 16 + px;
font-size: 1.6rem;

但是我不知道要传递expect什么以及放入什么to.equal。我正在尝试上面的事情,但我失败了。我总是得到这个:

/*! sassyjson - v1.1.8 - 2014-06-01 */
/* >> Bootcamp >> */
test block \: mixin font-size should expect positive values to be calculated correctly {
  ✗: Expected "@include font-size(1.2);" to equal "font-size: 16px;font-size: 1.6rem;";
  Test: Failed; }

Test Results {
  Success: false;
  Stats:  ✗;
  Tests: 1;
  Asserts: 1;
  Passed: 0;
  Failed: 1;
  Skipped: 0; }

/* << Bootcamp << */

我想要得到它是这样的:

@charset "UTF-8";
/*! sassyjson - v1.1.8 - 2014-06-01 */
/* >> Bootcamp >> */
Test Results {
  Success: true;
  Stats:  ✔;
  Tests: 1;
  Asserts: 1;
  Passed: 1;
  Failed: 0;
  Skipped: 0; }

/* << Bootcamp << */

任何想法或某个地方我可以检查以修复我的错误?谢谢

4

0 回答 0