From 0444dc2a38520dd1f9e56b401a2e63b5af458b72 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 8 Apr 2021 12:01:54 +0300 Subject: [PATCH] #23 add tests for extension --- .travis.yml | 3 ++- jest.config.js | 2 +- package.json | 2 ++ .../SetPassword/SetPassword.test.jsx | 20 ++++++++++--------- src/extension/inpage-script/donation.test.js | 10 ++++++++++ 5 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 src/extension/inpage-script/donation.test.js diff --git a/.travis.yml b/.travis.yml index 63a8b1dfdf..320f6cc5ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ before_script: - yarn install script: - yarn lint - - yarn build \ No newline at end of file + - yarn build + - yarn run test \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 2cbe36b167..2754a73a9f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { verbose: true, transform: { - "^.+\\.(jsx)$": "babel-jest", + "^.+\\.(js|jsx)$": "babel-jest", }, moduleNameMapper: { "^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": diff --git a/package.json b/package.json index 91b647374f..2b838661ee 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "lint": "eslint . --ext .js,.jsx --max-warnings 0", "lint:fix": "eslint . --ext .js,.jsx --fix", "format": "prettier --loglevel silent --write \"**/*.(js|ts|jsx|tsx)\"", + "test-ext": "jest ./src/extension", + "test-app": "jest ./src/app", "test": "jest" }, "husky": { diff --git a/src/app/components/SetPassword/SetPassword.test.jsx b/src/app/components/SetPassword/SetPassword.test.jsx index c16c847aab..a51fd658b2 100644 --- a/src/app/components/SetPassword/SetPassword.test.jsx +++ b/src/app/components/SetPassword/SetPassword.test.jsx @@ -3,14 +3,16 @@ import renderer from "react-test-renderer"; import SetPassword from "./index"; -test("Link changes the class when hovered", () => { - const handlePasswordModalOk = () => { - console.log("handlePasswordModalOk"); - }; - const component = renderer.create( - - ); +describe("SetPassword Component", () => { + test("should have correct title", () => { + const handlePasswordModalOk = () => { + console.log("handlePasswordModalOk"); + }; + const component = renderer.create( + + ); - const tree = component.toTree(); - expect(tree.rendered.props.title).toEqual("Your Password"); + const tree = component.toTree(); + expect(tree.rendered.props.title).toEqual("Your Password"); + }); }); diff --git a/src/extension/inpage-script/donation.test.js b/src/extension/inpage-script/donation.test.js new file mode 100644 index 0000000000..09d91eefa0 --- /dev/null +++ b/src/extension/inpage-script/donation.test.js @@ -0,0 +1,10 @@ +import Donation from "./donation"; + +describe("Donation", () => { + test("should generate correct hash", () => { + const donation = new Donation("test-location"); + expect(donation.getHash()).toEqual( + "ae9235c77e2e0c9853d8204badc33379a175d3e75349438a254778170a19b091" + ); + }); +});