diff --git a/test/__snapshots__/functional.test.ts.snap b/test/__snapshots__/functional.test.ts.snap
new file mode 100644
index 0000000..2782d42
--- /dev/null
+++ b/test/__snapshots__/functional.test.ts.snap
@@ -0,0 +1,19 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Connected Components React Plugin - Functional ComponentWithChildren.jsx snippet creation 1`] = `
+Object {
+ "description": "",
+ "lang": "jsx",
+ "snippet": "
+ {children}
+",
+}
+`;
+
+exports[`Connected Components React Plugin - Functional FunctionalComponents.jsx snippet creation 1`] = `
+Object {
+ "description": "",
+ "lang": "jsx",
+ "snippet": "",
+}
+`;
diff --git a/test/functional.test.ts b/test/functional.test.ts
new file mode 100644
index 0000000..bf3b7df
--- /dev/null
+++ b/test/functional.test.ts
@@ -0,0 +1,29 @@
+import Plugin from "../src";
+
+describe("Connected Components React Plugin - Functional", () => {
+ test("FunctionalComponents.jsx snippet creation", async () => {
+ const plugin = new Plugin();
+
+ const componentCode = await plugin.process(
+ {
+ path: "test/samples/jsx-functional/FunctionalComponent.jsx",
+ zeplinNames: []
+ }
+ );
+
+ expect(componentCode).toMatchSnapshot();
+ });
+
+ test("ComponentWithChildren.jsx snippet creation", async () => {
+ const processor = new Plugin();
+
+ const componentCode = await processor.process(
+ {
+ path: "test/samples/jsx-functional/FunctionalComponentWithChildren.jsx",
+ zeplinNames: []
+ }
+ );
+
+ expect(componentCode).toMatchSnapshot();
+ });
+});
diff --git a/test/propType.test.ts b/test/propType.test.ts
index e9f972a..dab93ba 100644
--- a/test/propType.test.ts
+++ b/test/propType.test.ts
@@ -6,7 +6,7 @@ describe("Connected Components React Plugin - PropTypes", () => {
const componentCode = await plugin.process(
{
- path: "test/samples/Component.jsx",
+ path: "test/samples/jsx-class/Component.jsx",
zeplinNames: []
}
);
@@ -19,7 +19,7 @@ describe("Connected Components React Plugin - PropTypes", () => {
const componentCode = await processor.process(
{
- path: "test/samples/ComponentWithChildren.jsx",
+ path: "test/samples/jsx-class/ComponentWithChildren.jsx",
zeplinNames: []
}
);
@@ -32,7 +32,7 @@ describe("Connected Components React Plugin - PropTypes", () => {
const componentCode = await processor.process(
{
- path: "test/samples/ComponentWithProps.jsx",
+ path: "test/samples/jsx-class/ComponentWithProps.jsx",
zeplinNames: []
}
);
@@ -45,7 +45,7 @@ describe("Connected Components React Plugin - PropTypes", () => {
const componentCode = await processor.process(
{
- path: "test/samples/ComponentWithChildrenAndProps.jsx",
+ path: "test/samples/jsx-class/ComponentWithChildrenAndProps.jsx",
zeplinNames: []
}
);
@@ -58,7 +58,7 @@ describe("Connected Components React Plugin - PropTypes", () => {
const componentCode = await processor.process(
{
- path: "test/samples/ComponentWithMemoization.jsx",
+ path: "test/samples/jsx-class/ComponentWithMemoization.jsx",
zeplinNames: []
}
);
diff --git a/test/samples/Component.jsx b/test/samples/jsx-class/Component.jsx
similarity index 100%
rename from test/samples/Component.jsx
rename to test/samples/jsx-class/Component.jsx
diff --git a/test/samples/ComponentWithChildren.jsx b/test/samples/jsx-class/ComponentWithChildren.jsx
similarity index 100%
rename from test/samples/ComponentWithChildren.jsx
rename to test/samples/jsx-class/ComponentWithChildren.jsx
diff --git a/test/samples/ComponentWithChildrenAndProps.jsx b/test/samples/jsx-class/ComponentWithChildrenAndProps.jsx
similarity index 100%
rename from test/samples/ComponentWithChildrenAndProps.jsx
rename to test/samples/jsx-class/ComponentWithChildrenAndProps.jsx
diff --git a/test/samples/ComponentWithMemoization.jsx b/test/samples/jsx-class/ComponentWithMemoization.jsx
similarity index 100%
rename from test/samples/ComponentWithMemoization.jsx
rename to test/samples/jsx-class/ComponentWithMemoization.jsx
diff --git a/test/samples/ComponentWithProps.jsx b/test/samples/jsx-class/ComponentWithProps.jsx
similarity index 100%
rename from test/samples/ComponentWithProps.jsx
rename to test/samples/jsx-class/ComponentWithProps.jsx
diff --git a/test/samples/jsx-functional/FunctionalComponent.jsx b/test/samples/jsx-functional/FunctionalComponent.jsx
new file mode 100644
index 0000000..feddca1
--- /dev/null
+++ b/test/samples/jsx-functional/FunctionalComponent.jsx
@@ -0,0 +1,17 @@
+import React from 'react';
+
+const MyComponent = () => {
+ const thing = {
+ stuff: 'stuff',
+ };
+
+ const string = thing?.stuff;
+
+ return (
+
+ {string}
+
+ );
+};
+
+export default MyComponent;
diff --git a/test/samples/jsx-functional/FunctionalComponentWithChildren.jsx b/test/samples/jsx-functional/FunctionalComponentWithChildren.jsx
new file mode 100644
index 0000000..922f358
--- /dev/null
+++ b/test/samples/jsx-functional/FunctionalComponentWithChildren.jsx
@@ -0,0 +1,21 @@
+import React from 'react';
+
+const MyComponent = () => {
+ const thing = {
+ stuff: 'stuff',
+ };
+
+ const string = thing?.stuff;
+
+ return (
+
+ {string}
+
+ );
+};
+
+MyComponent.propTypes = {
+ children: PropTypes.element.isRequired
+};
+
+export default MyComponent;