diff --git a/jest.config.js b/jest.config.js index 8d80a6e..74e652e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,6 +10,7 @@ module.exports = { transformIgnorePatterns: [`node_modules/(?!(gatsby)/)`], globals: { __PATH_PREFIX__: ``, + __BASE_PATH__: ``, }, setupFiles: [`/loadershim.js`], setupFilesAfterEnv: ["/setupTests.js"], diff --git a/src/components/__tests__/__snapshots__/addons.test.js.snap b/src/components/__tests__/__snapshots__/addons.test.js.snap index 8e58ffe..439d721 100644 --- a/src/components/__tests__/__snapshots__/addons.test.js.snap +++ b/src/components/__tests__/__snapshots__/addons.test.js.snap @@ -129,3 +129,2084 @@ exports[`Addons renders correctly 1`] = ` `; + +exports[`Addons should display workflow details if devDynamicBlogs and dev social data are available 1`] = ` +
+
+ download + + + blog-post-workflow.yml + + + file(learn + + + how to setup + + ) +
+
+`; + +exports[`Addons should display workflow details if mediumDynamicBlogs, medium social data are available 1`] = ` +
+
+ download + + + blog-post-workflow.yml + + + file(learn + + + how to setup + + ) +
+
+`; + +exports[`Addons should display workflow details if rssDynamicBlogs and rss url data are available 1`] = ` +
+
+ download + + + blog-post-workflow.yml + + + file(learn + + + how to setup + + ) +
+
+`; + +exports[`Addons should render Customize Badges 1`] = ` + +
+
+ Add-ons +
+ + } + title="Customize Badge" + /> + } + inputChecked={false} + inputId="visitors-count" + onInputChange={[Function]} + > +
+ + +
+ + } + title="Customize Badge" + > +
+
+ Customize Badge +
+
+
+ + + + + + Preview:  + + + +
+
+
+
+ +
+ +
+
+ + } + title="Customize Github Stats Card" + /> + } + inputChecked={false} + inputId="github-stats" + onInputChange={[Function]} + > +
+ + +
+
+ + } + title="Customize Top Skills Card" + /> + } + inputChecked={false} + inputId="top-languages" + onInputChange={[Function]} + > +
+ + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ download + + + blog-post-workflow.yml + + + file(learn + + + how to setup + + ) +
+
+
+
+`; + +exports[`Addons should render Customize Github stats card 1`] = ` + +
+
+ Add-ons +
+ + } + title="Customize Badge" + /> + } + inputChecked={false} + inputId="visitors-count" + onInputChange={[Function]} + > +
+ + +
+
+ +
+ +
+
+ + } + title="Customize Github Stats Card" + /> + } + inputChecked={false} + inputId="github-stats" + onInputChange={[Function]} + > +
+ + +
+ + } + title="Customize Github Stats Card" + > +
+
+ Customize Github Stats Card +
+
+
+ + + + + + + + + +
+
+
+
+ + } + title="Customize Top Skills Card" + /> + } + inputChecked={false} + inputId="top-languages" + onInputChange={[Function]} + > +
+ + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ download + + + blog-post-workflow.yml + + + file(learn + + + how to setup + + ) +
+
+
+
+`; + +exports[`Addons should render Customize Top Skills Card 1`] = ` + +
+
+ Add-ons +
+ + } + title="Customize Badge" + /> + } + inputChecked={false} + inputId="visitors-count" + onInputChange={[Function]} + > +
+ + +
+
+ +
+ +
+
+ + } + title="Customize Github Stats Card" + /> + } + inputChecked={false} + inputId="github-stats" + onInputChange={[Function]} + > +
+ + +
+
+ + } + title="Customize Top Skills Card" + /> + } + inputChecked={false} + inputId="top-languages" + onInputChange={[Function]} + > +
+ + +
+ + } + title="Customize Top Skills Card" + > +
+
+ Customize Top Skills Card +
+
+
+ + + + + + + + + +
+
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ download + + + blog-post-workflow.yml + + + file(learn + + + how to setup + + ) +
+
+
+
+`; diff --git a/src/components/__tests__/__snapshots__/markdownPreview.test.js.snap b/src/components/__tests__/__snapshots__/markdownPreview.test.js.snap index f236a83..599c97b 100644 --- a/src/components/__tests__/__snapshots__/markdownPreview.test.js.snap +++ b/src/components/__tests__/__snapshots__/markdownPreview.test.js.snap @@ -1,69 +1,578 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DisplaySocial Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`DisplaySocial Preview renders correctly 1`] = ` + + props.username + +`; -exports[`DisplaySocial Preview renders correctly with no username 1`] = `ShallowWrapper {}`; +exports[`DisplaySocial Preview renders correctly with no username 1`] = `""`; -exports[`DisplayWork Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly 1`] = ` +
+ [object Object] + + readme-generator + +
+`; -exports[`DisplayWork Preview renders correctly with no link 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no link 1`] = ` +
+ [object Object] + + readme-generator + +
+`; -exports[`DisplayWork Preview renders correctly with no prefix 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no prefix 1`] = `""`; -exports[`DisplayWork Preview renders correctly with no prefix and link 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no prefix and link 1`] = `""`; -exports[`DisplayWork Preview renders correctly with no prefix, link and project 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no prefix, link and project 1`] = `""`; -exports[`DisplayWork Preview renders correctly with no project 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no project 1`] = ` +
+ [object Object] + + https://dummy.com + +
+`; -exports[`DisplayWork Preview renders correctly with no project and link 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no project and link 1`] = `""`; -exports[`DisplayWork Preview renders correctly with no project and prefix 1`] = `ShallowWrapper {}`; +exports[`DisplayWork Preview renders correctly with no project and prefix 1`] = `""`; -exports[`GitHubStats Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`GitHubStats Preview renders correctly 1`] = `""`; -exports[`GitHubStats Preview renders correctly 2`] = `ShallowWrapper {}`; +exports[`GitHubStats Preview renders correctly 2`] = ` +
+ +
+`; -exports[`GithubProfileTrophy Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`GithubProfileTrophy Preview renders correctly 1`] = `""`; -exports[`GithubProfileTrophy Preview renders correctly with show true 1`] = `ShallowWrapper {}`; +exports[`GithubProfileTrophy Preview renders correctly with show true 1`] = ` +
+ + + + + +
+`; -exports[`Markdown Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`Markdown Preview renders correctly 1`] = ` +
+ + + + + + + + +
+ + +
+
+`; -exports[`SectionTitle Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`SectionTitle Preview renders correctly 1`] = ` +

+ dummy +

+`; -exports[`SectionTitle Preview renders correctly with no label 1`] = `ShallowWrapper {}`; +exports[`SectionTitle Preview renders correctly with no label 1`] = `""`; -exports[`SectionTitle Preview renders correctly with visible false 1`] = `ShallowWrapper {}`; +exports[`SectionTitle Preview renders correctly with visible false 1`] = `""`; -exports[`Skills Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`Skills Preview renders correctly 1`] = ` +
+ + + unity + +
+`; -exports[`Skills Preview renders correctly with no skills 1`] = `ShallowWrapper {}`; +exports[`Skills Preview renders correctly with no skills 1`] = `""`; -exports[`Social Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`Social Preview renders correctly 1`] = ` +
+ + + + + + + + + + + + + + + + + + + + + + + +
+`; -exports[`SubTitle Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`SubTitle Preview renders correctly 1`] = ` +

+ A passionate frontend developer from India +

+`; -exports[`SubTitle Preview renders correctly with no subtitle 1`] = `ShallowWrapper {}`; +exports[`SubTitle Preview renders correctly with no subtitle 1`] = `""`; -exports[`Title Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`Title Preview renders correctly 1`] = ` +

+ Hi 👋, I'm dummy +

+`; -exports[`Title Preview renders correctly with no prefix 1`] = `ShallowWrapper {}`; +exports[`Title Preview renders correctly with no prefix 1`] = `""`; -exports[`Title Preview renders correctly with no title 1`] = `ShallowWrapper {}`; +exports[`Title Preview renders correctly with no title 1`] = `""`; -exports[`Title Preview renders correctly with no title and prefix 1`] = `ShallowWrapper {}`; +exports[`Title Preview renders correctly with no title and prefix 1`] = `""`; -exports[`TopLanguages Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`TopLanguages Preview renders correctly 1`] = ` +
+   +
+`; -exports[`TopLanguages Preview renders correctly with show true 1`] = `ShallowWrapper {}`; +exports[`TopLanguages Preview renders correctly with show true 1`] = ` +
+ +
+`; -exports[`TwitterBadgePreview Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`TwitterBadgePreview Preview renders correctly 1`] = `""`; -exports[`TwitterBadgePreview Preview renders correctly with show true 1`] = `ShallowWrapper {}`; +exports[`TwitterBadgePreview Preview renders correctly with show true 1`] = ` +
+ + + + + +
+`; -exports[`VisitorsBadge Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`VisitorsBadge Preview renders correctly 1`] = `""`; -exports[`VisitorsBadge Preview renders correctly with show true 1`] = `ShallowWrapper {}`; +exports[`VisitorsBadge Preview renders correctly with show true 1`] = ` +
+ + + +
+`; -exports[`Work Preview renders correctly 1`] = `ShallowWrapper {}`; +exports[`Work Preview renders correctly 1`] = ` + + + + + + + + + + + + +`; diff --git a/src/components/__tests__/addons.test.js b/src/components/__tests__/addons.test.js index 034ae22..0402628 100644 --- a/src/components/__tests__/addons.test.js +++ b/src/components/__tests__/addons.test.js @@ -1,9 +1,11 @@ import React from "react" import toJson from "enzyme-to-json" -import { shallow } from "enzyme" +import { shallow, mount } from "enzyme" import Addons from "../addons" +jest.useFakeTimers(); + describe("Addons", () => { const dataInput = { title: "", @@ -92,4 +94,673 @@ describe("Addons", () => { expect(toJson(addOnComponent)).toMatchSnapshot(); }); + + it("should render Customize Badges", () => { + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#visitors-count-open-btn").simulate("click",{}); + + expect(addOnComponent).toMatchSnapshot(); + }); + + it("should handle data change when badge style is changed", () => { + const mockEvent = { target: { value: "style-new" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + titleColor: "title-abcd", + textColor: "some-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + locale: "en", + }, + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#visitors-count-open-btn").simulate("click",{}); + addOnComponent.find("#badge-style").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('badgeStyle',{target: {value: "style-new" }}); + }); + + it("should handle data change when badge color is changed", () => { + const mockEvent = { target: { value: "new-color-abcd" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#visitors-count-open-btn").simulate("click",{}); + addOnComponent.find("#badge-color").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('badgeColor',{target: {value: "new-color-abcd" }}); + }); + + it("should handle data change when badge-label-text is changed", () => { + const mockEvent = { target: { value: "label-abcd-random" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#visitors-count-open-btn").simulate("click",{}); + addOnComponent.find("#badge-label-text").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('badgeLabel',{target: {value: "label-abcd-random" }}); + }); + + it("should render Customize Github stats card", () => { + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + + expect(addOnComponent).toMatchSnapshot(); + }); + + it("should handle data change when stats theme is changed", () => { + const mockEvent = { target: { value: "new-theme-for-stats" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + titleColor: "title-abcd", + textColor: "some-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + addOnComponent.find("#stats-theme").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "title-abcd", + textColor: "some-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + } + }); + }); + + it("should handle data change when stats title color is changed", () => { + const mockEvent = { target: { value: "red-color" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + textColor: "some-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + addOnComponent.find("#stats-title-color").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "red-color", + textColor: "some-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + } + }); + }); + + it("should handle data change when stats bg color is changed", () => { + const mockEvent = { target: { value: "random-color" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + addOnComponent.find("#stats-bg-color").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + } + }); + }); + + it("should handle data change when stats cache seconds is changed", () => { + const mockEvent = { target: { value: 1900 } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + addOnComponent.find("#stats-cache-seconds").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: false, + cacheSeconds: 1900, + theme: "new-theme-for-stats", + locale: "en", + } + } + }); + }); + + it("should handle data change when stats text color is changed", () => { + const mockEvent = { target: { value: "black-color" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + titleColor: "some-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + addOnComponent.find("#stats-text-color").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "some-color", + textColor: "black-color", + bgColor: "abcd", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + } + }); + }); + + it("should handle data change when stats local is changed", () => { + const mockEvent = { target: { value: 'uk' } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click", {}); + addOnComponent.find("#stats-locale").simulate("change", mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "uk", + } + } + }); + }); + + it("should handle data change when stats local is changed", () => { + const mockEvent = { target: { checked: true } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + githubStatsOptions: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: false, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#github-stats-open-btn").simulate("click",{}); + addOnComponent.find("#stats-hide-border").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('githubStatsOptions', { + target: { + value: { + theme: "theme-1", + titleColor: "some-color", + textColor: "abcd", + bgColor: "random-color", + hideBorder: true, + cacheSeconds: null, + theme: "new-theme-for-stats", + locale: "en", + } + } + }); + }) + + it("should render Customize Top Skills Card", () => { + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#top-languages-open-btn").simulate("click",{}); + + expect(addOnComponent).toMatchSnapshot(); + }); + + it("should handle data change when top skills theme is changed", () => { + const mockEvent = { target: { value: "theme-xyz" } } + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value", + topLanguagesOptions : { + theme: "theme-2", + titleColor: "title-abcd-new", + textColor: "random-some-color", + bgColor: "1234", + hideBorder: false, + cacheSeconds: null, + theme: "theme-xyz", + locale: "us", + } + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = mount(); + + addOnComponent.find("#top-languages-open-btn").simulate("click",{}); + addOnComponent.find("#top-lang-theme").simulate("change",mockEvent); + + jest.runAllTimers(); + + expect(mockHandleDataChange).toHaveBeenCalledTimes(1); + expect(mockHandleDataChange).toHaveBeenCalledWith('topLanguagesOptions', { + target: { + value: { + theme: "theme-2", + titleColor: "title-abcd-new", + textColor: "random-some-color", + bgColor: "1234", + hideBorder: false, + cacheSeconds: null, + theme: "theme-xyz", + locale: "us", + } + } + }); + }); + + it("should handle check change when add on item inputs are changed", () => { + const mockEvent = { target: { value: "This is a mock event" } } + + const addOnComponent = mount(); + + addOnComponent.find("#visitors-count").simulate("change", mockEvent); + addOnComponent.find("#github-profile-trophy").simulate("change", mockEvent); + addOnComponent.find("#github-stats").simulate("change", mockEvent); + addOnComponent.find("#top-languages").simulate("change", mockEvent); + addOnComponent.find("#twitter-badge").simulate("change", mockEvent); + addOnComponent.find("#dev-dynamic-blogs").simulate("change", mockEvent); + addOnComponent.find("#rss-dynamic-blogs").simulate("change", mockEvent); + addOnComponent.find("#medium-dynamic-blogs").simulate("change", mockEvent); + + expect(mockHandleCheckChange).toHaveBeenCalledTimes(8); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(1,"visitorsBadge"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(2,"githubProfileTrophy"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(3,"githubStats"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(4,"topLanguages"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(5,"twitterBadge"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(6,"devDynamicBlogs"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(7,"rssDynamicBlogs"); + expect(mockHandleCheckChange).toHaveBeenNthCalledWith(8,"mediumDynamicBlogs"); + }); + + it("should display workflow details if devDynamicBlogs and dev social data are available", () => { + const newDataInput = { + ...dataInput, + devDynamicBlogs: "some-value" + }; + + const newSocialInput = { + dev: "some-value-123", + }; + + const addOnComponent = shallow(); + + const workflowElement = addOnComponent.find(".workflow"); + expect(workflowElement).toMatchSnapshot(); + }); + + it("should display workflow details if rssDynamicBlogs and rss url data are available", () => { + const newDataInput = { + ...dataInput, + rssDynamicBlogs: "some-rss-value" + }; + + const newSocialInput = { + rssurl: "url-random", + }; + + const addOnComponent = shallow(); + + const workflowElement = addOnComponent.find(".workflow"); + expect(workflowElement).toMatchSnapshot(); + }); + + it("should display workflow details if mediumDynamicBlogs, medium social data are available", () => { + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = shallow(); + + const workflowElement = addOnComponent.find(".workflow"); + expect(workflowElement).toMatchSnapshot(); + }); + + it("should call document create element when blog post workflow is clicked", () => { + let someElement = document.createElement("abcd"); + document.createElement = jest.fn().mockReturnValueOnce(someElement); + + const newDataInput = { + ...dataInput, + mediumDynamicBlogs: "some-medium-blogs-value" + }; + + const newSocialInput = { + medium: "@abcd", + }; + + const addOnComponent = shallow(); + + addOnComponent.find("#blog-post-worklow-span").simulate("click", {}); + expect(document.createElement).toHaveBeenCalledTimes(1); + }); }); \ No newline at end of file diff --git a/src/components/addons.js b/src/components/addons.js index eb6d609..14c6517 100644 --- a/src/components/addons.js +++ b/src/components/addons.js @@ -23,6 +23,7 @@ const AddonsItem = ({ inputId, inputChecked, onInputChange, Options, onIconClick {Options && (