Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fixtures/app-export-default-with-backticks.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import { webViewRender } from "react-native-react-bridge/lib/web";
import Comp from "./Component";
import "./example.css";

const text = "foo `bar`";
console.log(text);
console.log(`baz`);

const App = () => {
return <Comp />;
};

export default webViewRender(App);
27 changes: 0 additions & 27 deletions src/plugin/__snapshots__/html.spec.js.snap

This file was deleted.

3,572 changes: 3,572 additions & 0 deletions src/plugin/__snapshots__/index.spec.js.snap

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/plugin/__snapshots__/metro.spec.js.snap

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/plugin/html.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ROOT_ID } from "../common";

const escape = (src) => src.replace(/`/g, "\\`");

export const createContent = (js) =>
`export default String.raw\`${wrapByHtml(js)}\`;`;
`export default String.raw\`${escape(wrapByHtml(js))}\`;`;

const wrapByHtml = (js) => `
<!DOCTYPE html>
Expand Down
14 changes: 0 additions & 14 deletions src/plugin/html.spec.js

This file was deleted.

36 changes: 36 additions & 0 deletions src/plugin/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as fs from "fs";
import * as path from "path";
import { transform } from "./";

const createPath = (filename) =>
path.join(__dirname, "../../fixtures", filename);
const readFixture = (filename) => fs.readFileSync(filename, "utf-8");

describe("transform", () => {
it("export default", async () => {
const filename = "app-export-default.jsx";
const filePath = createPath(filename);
const src = readFixture(filePath);
expect(
await transform({ filename: filePath, src, options: {} })
).toMatchSnapshot();
});

it("export default with backticks", async () => {
const filename = "app-export-default-with-backticks.jsx";
const filePath = createPath(filename);
const src = readFixture(filePath);
expect(
await transform({ filename: filePath, src, options: {} })
).toMatchSnapshot();
});

it("export default with md", async () => {
const filename = "app-export-default-with-md.jsx";
const filePath = createPath(filename);
const src = readFixture(filePath);
expect(
await transform({ filename: filePath, src, options: {} })
).toMatchSnapshot();
});
});
7 changes: 7 additions & 0 deletions src/plugin/metro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ describe("bundle", () => {
expect(res).toMatchSnapshot();
});

it("with backticks", async () => {
const filename = "app-export-default-with-backticks.jsx";
const filePath = resolvePath(filename);
const res = await bundle(filePath);
expect(res).toMatchSnapshot();
});

it("default (preact)", async () => {
const filename = "app-export-default-preact.jsx";
const filePath = resolvePath(filename);
Expand Down