At the bottom of the message I'll paste the test file I have so far, so you can see some context for what I'm talking about. Maybe you know of ways to solve these problems with tape?
Those are my concerns. What do you think? Can we solve them with tape? Should we switch to Mocha?
import test from "tape"
import testRule from "../../../testUtils/testRule"
import blockOpeningBraceBefore from ".."
import { messages } from ".."
const testRule = testRule(blockOpeningBraceBefore)
test("block-opening-brace-before success", t => {
t.test("with `space`", st => {
st.plan(4)
testRule("body { color: pink; }", "space", warnings => {
st.equal(warnings.length, 0, "single-line rule")
})
testRule("body {\n\tcolor: pink;\n}", "space", warnings => {
st.equal(warnings.length, 0, "multi-line rule")
})
testRule("@media print { color: pink; }", "space", warnings => {
st.equal(warnings.length, 0, "single-line at-rule")
})
testRule("@media print {\n\tcolor: pink;\n}", "space", warnings => {
st.equal(warnings.length, 0, "multi-line at-rule")
})
})
t.test("with `newline`", st => {
st.plan(2)
testRule("body\n{ color: pink; }", "newline", warnings => {
st.equal(warnings.length, 0, "multi-line rule")
})
testRule("@media print\n{\n\tcolor: pink;\n}", "newline", warnings => {
st.equal(warnings.length, 0, "multi-line at-rule")
})
})
t.test("with `{ singleLine: `space`, multiLine: `space` }`", st => {
const options = { singleLine: "space", multiLine: "space" }
st.plan(4)
testRule("body { color: pink; }", options, warnings => {
st.equal(warnings.length, 0, "single-line rule")
})
testRule("body {\n\tcolor: pink;\n}", options, warnings => {
st.equal(warnings.length, 0, "multi-line rule")
})
testRule("@media print { color: pink; }", options, warnings => {
st.equal(warnings.length, 0, "single-line at-rule")
})
testRule("@media print {\n\tcolor: pink;\n}", options, warnings => {
st.equal(warnings.length, 0, "multi-line at-rule")
})
})
t.test("with `{ singleLine: `space`, multiLine: `newline` }`", st => {
const options = { singleLine: "space", multiLine: "newline" }
st.plan(4)
testRule("body { color: pink; }", options, warnings => {
st.equal(warnings.length, 0, "single-line rule")
})
testRule("body\n{\n\tcolor: pink;\n}", options, warnings => {
st.equal(warnings.length, 0, "multi-line rule")
})
testRule("@media print { color: pink; }", options, warnings => {
st.equal(warnings.length, 0, "single-line at-rule")
})
testRule("@media print\n{\n\tcolor: pink;\n}", options, warnings => {
st.equal(warnings.length, 0, "multi-line at-rule")
})
})
t.end()
})
test.only("block-opening-brace-before failure", t => {
t.test("warns when there are no whitespaces before opening brace", st => {
st.plan(8)
testRule("body{ color: pink; }", "space", warnings => {
st.equal(warnings.length, 1, "with `space` setting and rule")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
testRule("body{ color: pink; }", "newline", warnings => {
st.equal(warnings.length, 1, "with `newline` setting and rule")
st.equal(warnings[0].text, messages.expected("newline"), "warning contains expected test")
})
testRule("@media print{ color: pink; }", "space", warnings => {
st.equal(warnings.length, 1, "with `space` setting and at-rule")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
testRule("@media print{ color: pink; }", "newline", warnings => {
st.equal(warnings.length, 1, "with `newline` setting and at-rule")
st.equal(warnings[0].text, messages.expected("newline"), "warning contains expected test")
})
})
t.test("when there are multiple whitespaces before opening brace", st => {
st.plan(8)
testRule("body { color: pink; }", "space", warnings => {
st.equal(warnings.length, 1, "warns with two spaces before brace of rule")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
testRule("body\n\t{ color: pink; }", "newline", warnings => {
st.equal(warnings.length, 1, "warns with \\n\\t before brace of rule")
st.equal(warnings[0].text, messages.expected("newline"), "warning contains expected test")
})
testRule("@media print { color: pink; }", "space", warnings => {
st.equal(warnings.length, 1, "warns with two spaces before brace of at-rule")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
testRule("@media print\n\t{ color: pink; }", "newline", warnings => {
st.equal(warnings.length, 1, "warns with \\n\\t before brace of at-rule")
st.equal(warnings[0].text, messages.expected("newline"), "warning contains expected test")
})
})
t.test("with `space`", st => {
st.plan(4)
testRule("body\n{ color: pink; }", "space", warnings => {
st.equal(warnings.length, 1, "warns if actual for rule is newline")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
testRule("@media print\n{ color: pink; }", "space", warnings => {
st.equal(warnings.length, 1, "warns if actual for at-rule is newline")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
})
t.test("with `newline`", st => {
st.plan(4)
testRule("body { color: pink; }", "newline", warnings => {
st.equal(warnings.length, 1, "warns if actual for rule is space")
st.equal(warnings[0].text, messages.expected("newline"), "warning contains expected test")
})
testRule("@media print { color: pink; }", "newline", warnings => {
st.equal(warnings.length, 1, "warns if actual for at-rule is space")
st.equal(warnings[0].text, messages.expected("newline"), "warning contains expected test")
})
})
t.test("with `{ singleLine: `space`, multiLine: `space` }`", st => {
const options = { singleLine: "space", multiLine: "space" }
st.plan(4)
testRule("body\n{\ncolor: pink; }", options, warnings => {
st.equal(warnings.length, 1, "warns if newline precedes multiline rule")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
testRule("@media print\n{\ncolor: pink; }", options, warnings => {
st.equal(warnings.length, 1, "warns if newline precedes multiline at-rule")
st.equal(warnings[0].text, messages.expected("space"), "warning contains expected test")
})
})
t.end()
})