Skip to content

Commit

Permalink
w.i.p: improve css tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lubegasimon committed Mar 26, 2024
1 parent ede5d1e commit f67f345
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions e2e/rescript-v10-JSX4/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"dir": "src",
"type": "dev"
},
{
"dir": "test",
"type": "dev"
},
{
"dir": "../../_build/default/packages/css/rescript"
},
Expand Down
35 changes: 35 additions & 0 deletions e2e/rescript-v10-JSX4/test/cx_support_test__test.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
open Vitest

let toBe = (e, x) => Expect.toBe(e, x->Js.Json.stringifyAny)

let expect = x => expect(CssJs.toJson(x)->Js.Json.stringifyAny)

describe("border-top-style", () => {
test("test output", _ => {
expect([%css("border-top-style: hidden")])->toBe({"borderTopStyle": "hidden"})
expect([%css("border-top-style: none")])->toBe({"borderTopStyle": "none"})
expect([%css("border-top-style: dotted")])->toBe({"borderTopStyle": "dotted"})
expect([%css("border-top-style: dashed ")])->toBe({"borderTopStyle": "dashed"})
expect([%css("border-top-style: solid")])->toBe({"borderTopStyle": "solid"})
expect([%css("border-top-style: double")])->toBe({"borderTopStyle": "double"})
expect([%css("border-top-style: groove")])->toBe({"borderTopStyle": "groove"})
expect([%css("border-top-style: ridge")])->toBe({"borderTopStyle": "ridge"})
expect([%css("border-top-style: inset")])->toBe({"borderTopStyle": "inset"})
expect([%css("border-top-style: outset")])->toBe({"borderTopStyle": "outset"})
})
})

describe("height", () => {
test("test output", _ => {
expect([%css("height: 80px")])->toBe({"height": "80px"})
expect([%css("height: 80%")])->toBe({"height": "80%"})
expect([%css("height: auto")])->toBe({"height": "auto"})
expect([%css("height: fit-content ")])->toBe({"height": "fit-content"})
expect([%css("height: max-content")])->toBe({"height": "max-content"})
expect([%css("height: min-content")])->toBe({"height": "min-content"})
expect([%css("height: calc(50% - 20px)")])->toBe({"height": "calc(50% - 20px)"})
expect([%css("height: calc(calc(100% - 20px) + calc(1vw / 2))")])->toBe({
"height": "calc(calc(100% - 20px) + calc(1vw * 2))", // FIXME: bug
})
})
})
2 changes: 1 addition & 1 deletion e2e/rescript-v10-JSX4/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfig } from 'vite';

/** @type {import('vite').UserConfig} */
export default defineConfig({
root: "src",
root: "test",
optimizeDeps: {
include: ['@emotion/css'],
},
Expand Down

0 comments on commit f67f345

Please sign in to comment.