我试图测试一段sass代码,更确切地说是一个混合代码。这一个:
// 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 << */
我可以检查以修复错误的任何想法或某个地方? 感谢