Skip to content
This repository was archived by the owner on Jan 27, 2024. It is now read-only.

Commit

Permalink
chore(tests): migrating from local bindings to @greenlabs/rescript-jest
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarcosp committed Nov 22, 2022
1 parent b0f1587 commit e420b42
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 216 deletions.
3 changes: 2 additions & 1 deletion core/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-jsx": 3
},
"suffix": ".bs.js",
"bs-dependencies": ["@rescript/react"],
"bs-dependencies": ["@rescript/react", "@greenlabs/rescript-jest"],
"bs-dev-dependencies": ["@greenlabs/rescript-jest"],
"ppx-flags": ["@greenlabs/ppx-ts/ppx"]
}
6 changes: 4 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
"@babel/core": "7.17.5",
"@emotion/css": "11.10.0",
"@emotion/jest": "11.9.3",
"@greenlabs/ppx-ts": "^0.1.6",
"@greenlabs/ppx-ts": "0.1.6",
"@greenlabs/rescript-jest": "^1.0.1",
"@rescript/react": "0.10.3",
"@storybook/addon-actions": "6.5.9",
"@storybook/addon-essentials": "6.5.9",
"@storybook/addon-interactions": "6.5.9",
"@storybook/addon-links": "6.5.9",
"@storybook/react": "6.5.9",
"@storybook/testing-library": "0.0.13",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/react-hooks": "8.0.1",
"babel-loader": "8.2.3",
"jest": "27.2.5",
"jsdom": "20.0.0",
Expand All @@ -34,6 +35,7 @@
"rescript": "10.0.1"
},
"peerDependencies": {
"@greenlabs/ppx-ts": ">=0.1.6",
"@rescript/react": ">=0.10.0",
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
Expand Down
69 changes: 0 additions & 69 deletions core/src/bindings/Ancestor_Jest.res

This file was deleted.

9 changes: 5 additions & 4 deletions core/src/components/box/Ancestor_Box_Test.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
open Ancestor_Jest
open Jest
open Expect
open Ancestor
module Renderer = Ancestor_ReactTestRenderer

describe("Box", (. ()) => {
it("should render with columns correctly", (. ()) => {
describe("Box", () => {
test("should render with columns correctly", () => {
expect(
Renderer.create(
<Box columns={xs: #6, md: #12, lg: #3}>
Expand All @@ -13,7 +14,7 @@ describe("Box", (. ()) => {
)->toMatchSnapshot
})

it("should render without columns correctly", (. ()) => {
test("should render without columns correctly", () => {
expect(
Renderer.create(
<Box>
Expand Down
9 changes: 5 additions & 4 deletions core/src/components/grid/Ancestor_Grid_Test.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
open Ancestor_Jest
open Jest
open Expect
open Ancestor

module Renderer = Ancestor_ReactTestRenderer

describe("Grid", (. ()) => {
it("should with spacing render correctly", (. ()) => {
describe("Grid", () => {
test("should with spacing render correctly", () => {
expect(
Renderer.create(
<Grid spacing={xs: 1, md: 0, lg: 3}>
Expand All @@ -17,7 +18,7 @@ describe("Grid", (. ()) => {
)->toMatchSnapshot
})

it("should without spacing render correctly", (. ()) => {
test("should without spacing render correctly", () => {
expect(
Renderer.create(
<Grid>
Expand Down
7 changes: 4 additions & 3 deletions core/src/components/hidden/Ancestor_Hidden_Test.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
open Ancestor_Jest
open Jest
open Expect
open Ancestor

module Renderer = Ancestor_ReactTestRenderer

describe("Hidden", (. ()) => {
it("should visually hide elements correctly", (. ()) => {
describe("Hidden", () => {
test("should visually hide elements correctly", () => {
expect(
Renderer.create(
<Hidden on={xs: true, md: false, lg: true}>
Expand Down
9 changes: 5 additions & 4 deletions core/src/components/stack/Ancestor_Stack_Test.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
open Ancestor_Jest
open Jest
open Expect
open Ancestor
module Renderer = Ancestor_ReactTestRenderer

describe("Stack", (. ()) => {
it("should render correctly", (. ()) => {
describe("Stack", () => {
test("should render correctly", () => {
expect(
Renderer.create(
<Stack direction={xs: #horizontal, md: #vertical}>
Expand All @@ -13,7 +14,7 @@ describe("Stack", (. ()) => {
)->toMatchSnapshot
})

it("should render with dividers correctly", (. ()) => {
test("should render with dividers correctly", () => {
let placeholder = <div> {`Placeholder`->React.string} </div>
let divider = <div> {`Divider`->React.string} </div>

Expand Down
27 changes: 14 additions & 13 deletions core/src/core/Ancestor_Styles_Test.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
open Ancestor_Jest
open Jest
open Expect

module Styles = Ancestor_Styles.Make(Ancestor.DefaultConfig)

describe("Styles", (. ()) => {
describe(".createCssValueFromArray", (. ()) => {
it(
describe("Styles", () => {
describe(".createCssValueFromArray", () => {
test(
"should create responsive CSS for the attribute provided",
(. ()) => {
() => {
let padding = Styles.createCssValueFromArray(
"padding",
Some({xs: 2, md: 4}),
Expand All @@ -25,21 +26,21 @@ describe("Styles", (. ()) => {
)
})

describe(".mediaQuery", (. ()) => {
it(
describe(".mediaQuery", () => {
test(
"should create a media query correctly",
(. ()) => {
() => {
let mediaQuery = Styles.mediaQuery("display: block;", Xs, "display: flex")

expect(mediaQuery)->toMatchSnapshot
},
)
})

describe(".createResponsiveProp", (. ()) => {
it(
describe(".createResponsiveProp", () => {
test(
"should create responsive styles correctly",
(. ()) => {
() => {
let styles = Styles.createResponsiveProp(
~prop=Some({xs: 1, md: 2}),
value => `padding: ${value->Js.Int.toString};`,
Expand All @@ -49,9 +50,9 @@ describe("Styles", (. ()) => {
},
)

it(
test(
"should add default styles correctly",
(. ()) => {
() => {
let styles = Styles.createResponsiveProp(
~prop=None,
~defaultStyles="border: solid 1px red;",
Expand Down
Loading

0 comments on commit e420b42

Please sign in to comment.