Browse Source

initial commit with @testing-library

develop
arunkumar 4 years ago
parent
commit
58f6a7250b
  1. 1746
      package-lock.json
  2. 12
      package.json
  3. 18
      test/compileReact.test.js

1746
package-lock.json

File diff suppressed because it is too large

12
package.json

@ -4,16 +4,22 @@
"description": "", "description": "",
"main": "", "main": "",
"scripts": { "scripts": {
"test": "mocha" "test": "mocha --require jsdom-global/register"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"chai": "^4.2.0", "chai": "^4.2.0",
"jsdom": "^16.4.0",
"jsdom-global": "^3.0.2",
"mocha": "^8.2.1", "mocha": "^8.2.1",
"react": "*" "react": "*",
"react-dom": "^17.0.1"
}, },
"peerDependencies": { "peerDependencies": {
"react": "*" "react": "*"
} },
"dependencies": {}
} }

18
test/compileReact.test.js

@ -0,0 +1,18 @@
const expect = require("chai").expect;
const CompileReact = require("../lib/compileReact");
const { render, screen } = require("@testing-library/react");
// require("@testing-library/jest-dom/extend-expect");
require("jsdom");
describe("Compile AST to REACT elements", function () {
it("Simple react elements", function () {
const ast = [
{
type: "underline",
children: ["The ", { type: "bold", children: ["Apple"] }],
},
];
render(CompileReact(ast));
expect(screen.getByText("Apple")).toHaveTextContent("Apple");
});
});
Loading…
Cancel
Save