From 821d30081102bcc611ad76da6ffa1230e914577e Mon Sep 17 00:00:00 2001 From: Brad Grzesiak Date: Tue, 28 Mar 2017 09:47:04 -0500 Subject: [PATCH 1/3] Add more testing dependencies --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e8ba1030..3f55d089 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,9 @@ }, "devDependencies": { "chai": "3.4.1", - "mocha": "2.3.4" + "mocha": "2.3.4", + "node-elm-compiler": "2.3.2", + "tmp": "0.0.28" }, "engineStrict": true, "engines": { From 70758143b9420dc23f6b52349b75cd47cf851b44 Mon Sep 17 00:00:00 2001 From: Brad Grzesiak Date: Tue, 28 Mar 2017 09:53:57 -0500 Subject: [PATCH 2/3] Extract media query tests into AtRules.elm --- tests/AtRules.elm | 86 ++++++++++++++++++++++++++++++++++++++++++++++ tests/Fixtures.elm | 4 +-- tests/Tests.elm | 76 ++-------------------------------------- 3 files changed, 90 insertions(+), 76 deletions(-) create mode 100644 tests/AtRules.elm diff --git a/tests/AtRules.elm b/tests/AtRules.elm new file mode 100644 index 00000000..1791ae80 --- /dev/null +++ b/tests/AtRules.elm @@ -0,0 +1,86 @@ +module AtRules exposing (all) + +import Test exposing (..) +import Expect exposing (Expectation) +import TestUtil exposing (outdented, prettyPrint) +import Fixtures + + +all : Test +all = + describe "at-rules" + [ mediaQueryTests + , nestedAtRules + ] + + +mediaQueryTests : Test +mediaQueryTests = + let + input = + Fixtures.mediaQueryAtRule + + output = + """ + body { + padding: 0; + } + + @media print { + body { + margin: 2em; + } + } + + @media screen and ( max-width: 600px ) { + body { + margin: 3em; + } + } + + button { + margin: auto; + } + """ + in + describe "@media test" + [ test "pretty prints the expected output" <| + \_ -> + outdented (prettyPrint input) + |> Expect.equal (outdented output) + ] + + +nestedAtRules : Test +nestedAtRules = + let + input = + Fixtures.nestedAtRule + + output = + """ + button { + padding: 0; + } + + body { + margin: auto; + } + + @media print { + body { + margin: 2em; + } + } + + a { + text-decoration: none; + } + """ + in + describe "nested @media test" + [ test "pretty prints the expected output" <| + \_ -> + outdented (prettyPrint input) + |> Expect.equal (outdented output) + ] diff --git a/tests/Fixtures.elm b/tests/Fixtures.elm index d2c8dd0f..80f2007d 100644 --- a/tests/Fixtures.elm +++ b/tests/Fixtures.elm @@ -32,8 +32,8 @@ divWidthHeight = ] -atRule : Stylesheet -atRule = +mediaQueryAtRule : Stylesheet +mediaQueryAtRule = (stylesheet << namespace "homepage") [ body [ padding zero ] , (media [ print ]) [ body [ margin (Css.em 2) ] ] diff --git a/tests/Tests.elm b/tests/Tests.elm index 0ca58b4d..4a335fcb 100644 --- a/tests/Tests.elm +++ b/tests/Tests.elm @@ -10,6 +10,7 @@ import Fixtures import Properties import Selectors import Colors +import AtRules all : Test @@ -23,8 +24,6 @@ all = , divWidthHeight , leftRightTopBottom , borders - , atRule - , nestedAtRule , bug99 , bug140 , universal @@ -42,6 +41,7 @@ all = , Properties.all , Selectors.all , Arithmetic.all + , AtRules.all , backgrounds ] @@ -145,78 +145,6 @@ leftRightTopBottom = ] -atRule : Test -atRule = - let - input = - Fixtures.atRule - - output = - """ - body { - padding: 0; - } - - @media print { - body { - margin: 2em; - } - } - - @media screen and ( max-width: 600px ) { - body { - margin: 3em; - } - } - - button { - margin: auto; - } - """ - in - describe "@media test" - [ test "pretty prints the expected output" <| - \_ -> - outdented (prettyPrint input) - |> Expect.equal (outdented output) - ] - - -nestedAtRule : Test -nestedAtRule = - let - input = - Fixtures.nestedAtRule - - output = - """ - button { - padding: 0; - } - - body { - margin: auto; - } - - @media print { - body { - margin: 2em; - } - } - - a { - text-decoration: none; - } - """ - in - describe "nested @media test" - [ test "pretty prints the expected output" <| - \_ -> - outdented (prettyPrint input) - |> Expect.equal (outdented output) - ] - - {-| Regression test for https://github.com/rtfeldman/elm-css/issues/140 -} bug140 : Test From 93db6acfe6de57f75c3a78d6d7ecc21a1f5f90d0 Mon Sep 17 00:00:00 2001 From: Brad Grzesiak Date: Tue, 28 Mar 2017 10:10:48 -0500 Subject: [PATCH 3/3] Add aspirational (non-working) test --- tests/AtRules.elm | 33 +++++++++++++++++++++++++++++++++ tests/Fixtures.elm | 22 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/tests/AtRules.elm b/tests/AtRules.elm index 1791ae80..dfe51e38 100644 --- a/tests/AtRules.elm +++ b/tests/AtRules.elm @@ -11,9 +11,42 @@ all = describe "at-rules" [ mediaQueryTests , nestedAtRules + , fontFaceTests ] +fontFaceTests : Test +fontFaceTests = + let + input = + Fixtures.fontFaceAtRule + + output = + """ + @font-face { + font-family: "MyFontName"; + src: url(https://example.com/fonts/MyFont-Weird.ttf), + url(https://example.com/fonts/MyFont-Odd.ttf); + font-variant: small-caps; + font-weight: 500; + font-style: italic; + } + + @font-face { + font-family: "MyFontName"; + src: url(https://example.com/fonts/MyFont-Bold.woff); + font-weight: bold; + } + """ + in + describe "@font-face" + [ test "pretty prints the expected output" <| + \_ -> + outdented (prettyPrint input) + |> Expect.equal (outdented output) + ] + + mediaQueryTests : Test mediaQueryTests = let diff --git a/tests/Fixtures.elm b/tests/Fixtures.elm index 80f2007d..e81e1d59 100644 --- a/tests/Fixtures.elm +++ b/tests/Fixtures.elm @@ -32,6 +32,28 @@ divWidthHeight = ] +fontFaceAtRule : Stylesheet +fontFaceAtRule = + -- NOTE: The following code is aspirational and does not compile (yet) + (stylesheet << namespace "homepage") + [ fontFace + [ fontFamily "MyFontName" + , src + [ url "https://example.com/fonts/MyFont-Weird.ttf" + , url "https://example.com/fonts/MyFont-Odd.ttf" + ] + , fontVariant smallCaps + , fontWeight <| int 500 + , fontStyle italic + ] + , fontFace + [ fontFamily "MyFontName" + , src <| url "https://example.com/fonts/MyFont-Bold.woff" + , fontWeight bold + ] + ] + + mediaQueryAtRule : Stylesheet mediaQueryAtRule = (stylesheet << namespace "homepage")