This repository has been archived by the owner on Jul 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* nearly done studies addition [ci skip] * fix tests and lints for studies * project adjustments for testing * added studies changes * fix failing ci test * add aphrodite reset to slider test * add in more aphrodite stuff * sheesh, add it to all new tests?
- Loading branch information
1 parent
f383ca6
commit 58bfc03
Showing
25 changed files
with
2,273 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,3 +67,4 @@ docs | |
|
||
# editor files | ||
.vscode | ||
.tsconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
export const DDP = { | ||
_CurrentInvocation: { | ||
get: jest.fn(() => {}), | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* eslint-disable */ | ||
import renderer from "react-test-renderer"; | ||
import { shallow } from "enzyme"; | ||
import { shallowToJson } from "enzyme-to-json"; | ||
import { reset, startBuffering } from "aphrodite/lib/inject"; | ||
|
||
beforeEach(() => { | ||
reset(); | ||
startBuffering(); | ||
}); | ||
|
||
afterEach(() => { | ||
reset(); | ||
}); | ||
|
||
import { | ||
StudyEntryWithoutData as StudyEntry, | ||
STUDY_ENTRY_QUERY, | ||
} from "../EntryList"; | ||
|
||
const defaultProps = { | ||
studyEntries: { | ||
loading: false, | ||
content: { | ||
studyEntries: [ | ||
{ | ||
title: "Study Entry" | ||
}, | ||
], | ||
}, | ||
}, | ||
light: true, | ||
focus: "1" | ||
}; | ||
|
||
const generateComponent = (additionalProps = {}) => { | ||
const newProps = { | ||
...defaultProps, | ||
...additionalProps, | ||
}; | ||
|
||
return <StudyEntry { ...newProps } />; | ||
}; | ||
|
||
it("parses study entry query", () => { | ||
expect(STUDY_ENTRY_QUERY).toMatchSnapshot(); | ||
}); | ||
|
||
it("renders with props", () => { | ||
const tree = renderer.create(generateComponent()); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it("returns null if there is no studyEntries", () => { | ||
const tree = renderer.create(generateComponent({ | ||
studyEntries: { | ||
content: { | ||
studyEntries: [], | ||
} | ||
}, | ||
})); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it("has a loading state", () => { | ||
const tree = renderer.create(generateComponent({ | ||
studyEntries: { | ||
loading: true | ||
}, | ||
})); | ||
expect(tree).toMatchSnapshot(); | ||
}) | ||
|
||
it("calculates width based on window size", () => { | ||
const wrapper = shallow(generateComponent()); | ||
const result = wrapper.instance().dynamicWidth(); | ||
expect(result).toEqual({ width: "847.2px" }); | ||
}); | ||
|
||
it("calculates tablet version", () => { | ||
window.isTablet = true; | ||
const wrapper = shallow(generateComponent()); | ||
const result = wrapper.instance().dynamicWidth(); | ||
expect(result).toEqual({ width: "429px" }); | ||
}); | ||
|
||
it("overflow contains css object", () => { | ||
const wrapper = shallow(generateComponent()); | ||
const result = wrapper.instance().overflow; | ||
expect(result).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable */ | ||
import renderer from "react-test-renderer"; | ||
import { reset, startBuffering } from "aphrodite/lib/inject"; | ||
|
||
import StudiesEntryListItem from "../EntryListItem"; | ||
|
||
beforeEach(() => { | ||
reset(); | ||
startBuffering(); | ||
}); | ||
|
||
afterEach(() => { | ||
reset(); | ||
}); | ||
|
||
describe("StudiesEntryListItem", () => { | ||
it("takes a single study as a prop", () => { | ||
const study = { | ||
"id": "e2a6f1a585c90a33b88f8e41b26c9ffe", | ||
"entryId": "e2a6f1a585c90a33b88f8e41b26c9ffe", | ||
"title": "Who are you trying to please?", | ||
"status": "open", | ||
"channelName": "study_entries", | ||
"parent": { | ||
"entryId": "9bff3ab47f41d1818fa3dc2803fa141b" | ||
}, | ||
"meta": { | ||
"urlTitle": "who-are-you-trying-to-please", | ||
"siteId": "393ebdf414cdf68c96bb7fd149f7a434", | ||
"date": "Wed Dec 07 2016 00:00:00 GMT+0000 (UTC)", | ||
"channelId": "d89926c004a563d46e0d10ca1a5fea53" | ||
}, | ||
"content": { | ||
"speaker": "" | ||
} | ||
}; | ||
|
||
const tree = renderer.create( | ||
<StudiesEntryListItem | ||
studyEntry={study} | ||
order={1} | ||
light={true} | ||
/> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable */ | ||
import renderer from "react-test-renderer"; | ||
import { reset, startBuffering } from "aphrodite/lib/inject"; | ||
|
||
import StudyHero from "../Hero"; | ||
|
||
beforeEach(() => { | ||
reset(); | ||
startBuffering(); | ||
}); | ||
|
||
afterEach(() => { | ||
reset(); | ||
}); | ||
|
||
describe("StudyHero", () => { | ||
it("changes class name based on props", () => { | ||
const study = { | ||
"content": { | ||
"isLight": true, | ||
"images":[ | ||
{ "url": "http://exampleimage.org" } | ||
] | ||
} | ||
}; | ||
|
||
const tree = renderer.create( | ||
<StudyHero study={study} /> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* eslint-disable */ | ||
import renderer from "react-test-renderer"; | ||
import { shallow, mount } from "enzyme"; | ||
import { reset, startBuffering } from "aphrodite/lib/inject"; | ||
|
||
import { StudiesSingleWithoutData } from "../Single"; | ||
import { | ||
nav as navActions, | ||
} from "../../../store"; | ||
import headerActions from "../../../store/header"; | ||
|
||
jest.mock("../../../database/collections/likes", () => {}); | ||
jest.mock("../../../blocks/related-content"); | ||
|
||
jest.mock("../../../mixins/mixins.Shareable"); | ||
jest.mock("../../../mixins/mixins.Header"); | ||
|
||
jest.mock("../EntryList"); | ||
jest.mock("../Hero"); | ||
|
||
jest.mock("../../../store/header", () => ({ | ||
set: jest.fn(), | ||
})); | ||
|
||
jest.mock("../../../store", () => ({ | ||
nav: { | ||
setLevel: jest.fn(), | ||
setAction: jest.fn(), | ||
}, | ||
})); | ||
|
||
const defaultProps = { | ||
dispatch: jest.fn(), | ||
params: { | ||
id: "1", | ||
}, | ||
study: { | ||
content: { | ||
id: "1", | ||
content: { | ||
description: "<h1>study</h1>", | ||
images: [], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
beforeEach(() => { | ||
reset(); | ||
startBuffering(); | ||
}); | ||
|
||
afterEach(() => { | ||
reset(); | ||
}); | ||
|
||
const generateComponent = (additionalProps = {}) => { | ||
const newProps = { | ||
...defaultProps, | ||
...additionalProps, | ||
}; | ||
|
||
return <StudiesSingleWithoutData { ...newProps } />; | ||
}; | ||
|
||
it("renders with no image", () => { | ||
const tree = renderer.create(generateComponent()); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it("renders loading with no study", () => { | ||
const tree = renderer.create(generateComponent({ | ||
study: {} | ||
})); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it("renders studies content", () => { | ||
const tree = renderer.create(generateComponent({ | ||
study: { | ||
content: { | ||
id: "1", | ||
content: { | ||
description: "<h1>study</h1>", | ||
images: [ | ||
{ fileLabel: "1:1", url: "http://test.com/1x1.jpg" }, | ||
], | ||
}, | ||
}, | ||
} | ||
})); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it("dispatches store on mount", () => { | ||
const mockDispatch = jest.fn(); | ||
|
||
navActions.setLevel = jest.fn(); | ||
navActions.setAction = jest.fn(); | ||
headerActions.set = jest.fn(); | ||
|
||
const wrapper = shallow(generateComponent({ | ||
dispatch: mockDispatch, | ||
})); | ||
|
||
expect(mockDispatch).toHaveBeenCalledTimes(3); | ||
expect(navActions.setLevel).toHaveBeenCalledTimes(1); | ||
expect(navActions.setLevel).toHaveBeenCalledWith("CONTENT"); | ||
expect(navActions.setAction).toHaveBeenCalledTimes(1); | ||
expect(navActions.setAction.mock.calls[0][0]).toBe("CONTENT"); | ||
expect(headerActions.set).toHaveBeenCalledTimes(1); | ||
}); |
Oops, something went wrong.