Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test #388

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2d23da0
WIP fetch enviroment varialble from json data
YehualashetGit May 17, 2021
33315c4
Merge branch 'master' of https://github.com/TheIOFoundation/ProjectLo…
YehualashetGit May 17, 2021
3ad95e4
WIP Loading Envt Variable
YehualashetGit May 19, 2021
ad220a0
Addressed Solar lint comment
YehualashetGit May 19, 2021
f4cb14e
address Solar and eslint comment
YehualashetGit May 19, 2021
117235d
WIP Load map style from env parameter
YehualashetGit May 19, 2021
c0f5a3b
Adress Sonar Lint issue
YehualashetGit May 19, 2021
c0ff83e
handle visibility of Components from Enviroment varable
YehualashetGit May 20, 2021
45e3d38
fix solar lint warning
YehualashetGit May 20, 2021
a1b062c
Load Legend Data from env variable
YehualashetGit May 21, 2021
0992d16
Able to load overlay title from enviromet data
YehualashetGit May 21, 2021
f6f2352
Fix Solar lint comment
YehualashetGit May 21, 2021
26017e8
Add QueryString for UI component
YehualashetGit May 24, 2021
0946e7a
Addresss Review comment
YehualashetGit May 25, 2021
3f1f279
remove mapstateConstant variale
YehualashetGit May 26, 2021
f146cc6
WIP Writing test for Components
YehualashetGit May 27, 2021
dc637ee
Merge branch 'master' into query-string
YehualashetGit May 27, 2021
79bcac9
Fix dark and light mode issue
YehualashetGit May 27, 2021
3740572
Add unit test and Readme
YehualashetGit May 28, 2021
ce7d973
Address Solar lint issue
YehualashetGit May 28, 2021
db6fc64
Display Overlay from Query String
YehualashetGit May 31, 2021
826e12c
Address Reivew Comment and fix test casess
YehualashetGit Jun 1, 2021
a9e1348
rename mock file under Lenged dir
YehualashetGit Jun 1, 2021
2c3e366
Fix typo
YehualashetGit Jun 1, 2021
86da51d
Merge branch 'master' of https://github.com/TheIOFoundation/ProjectLo…
YehualashetGit Jun 1, 2021
7e96d83
Fix Sona issue for converting string boolean
YehualashetGit Jun 5, 2021
c01ea7f
Adressed Sonar Review comment in Map.js file
YehualashetGit Jun 5, 2021
2de174f
load Snaphot value from Enviroment data
YehualashetGit Jun 8, 2021
7a5f884
update snapshot data
YehualashetGit Jun 8, 2021
d8211ac
Fix Dark theme issue and add snapshpot data
YehualashetGit Jun 9, 2021
30d3666
Remove todo comments
YehualashetGit Jun 9, 2021
fbc9eb0
Merge branch 'master' of https://github.com/TheIOFoundation/ProjectLo…
YehualashetGit Jun 9, 2021
a0b3741
remove console.log
YehualashetGit Jun 10, 2021
2981d13
Fix Dark theme issue
YehualashetGit Jun 10, 2021
164951f
Fix Dark theme issue and remove unsued file
YehualashetGit Jun 11, 2021
a920670
Merge branch 'master' of https://github.com/TheIOFoundation/ProjectLo…
YehualashetGit Jun 11, 2021
92e66b2
add test case for Legend Component to include context data
YehualashetGit Jun 11, 2021
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
9 changes: 6 additions & 3 deletions MAP/src/components/Legend/test/Legend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ it('renders correctly when there are no items', () => {
expect(tree).toMatchSnapshot();
});

it('render Correctly with context data' , async () => {
it('>>>render Correctly with context data' , async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do the >>> mean? does it do something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noo it doesn't have any meaning :) lol

const tree = renderer.create(
<AppContext.Provider value={envMock}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking it might make sense for someone debugging this test in the future, if you edit the envMock right before creating the const tree so that when viewing the test code, it's easy to see what the expected content will be. for example:

let usedEnv = envMock
usedMock.components[1] = {
    "name":"Legend",
    "is_visible": true,
    "data": [
        {
            "title": "mapLegend.no",
            "worldStyle": "2"
        },
}

then you also don't need to keep changing the mock for each test case

<Legend {...props} />
</AppContext.Provider>
);
expect(tree).toMatchSnapshot();
).root;
// query for element
const element = tree.findByType("div");

expect(element.props.children.length).toEqual(4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good start, can we also check if the text or color of the item is "expected"

})

104 changes: 5 additions & 99 deletions MAP/src/components/Legend/test/__snapshots__/Legend.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,110 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`render Correctly with context data 1`] = `
<legend
className="btn "
dark="false"
ii8n={[Function]}
onClick={[Function]}
t={[Function]}
tab="dailyLife"
type="legend"
x="left"
y="bottom"
>
<svg
fill="none"
height="30"
viewBox="0 0 33 30"
width="33"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M2.95234 13.7899C4.58287 13.7899 5.90468 12.4681 5.90468 10.8376C5.90468 9.20706 4.58287 7.88525 2.95234 7.88525C1.32181 7.88525 0 9.20706 0 10.8376C0 12.4681 1.32181 13.7899 2.95234 13.7899Z"
fill="#F2994A"
/>
<path
d="M2.95432 5.89301C4.58163 5.89301 5.90082 4.57381 5.90082 2.9465C5.90082 1.3192 4.58163 0 2.95432 0C1.32701 0 0.0078125 1.3192 0.0078125 2.9465C0.0078125 4.57381 1.32701 5.89301 2.95432 5.89301Z"
fill="#6FCF97"
/>
<path
d="M2.95234 29.6054C4.58287 29.6054 5.90468 28.2836 5.90468 26.653C5.90468 25.0225 4.58287 23.7007 2.95234 23.7007C1.32181 23.7007 0 25.0225 0 26.653C0 28.2836 1.32181 29.6054 2.95234 29.6054Z"
fill="#CCCCCC"
/>
<path
d="M2.95334 21.7075C4.58065 21.7075 5.89984 20.3883 5.89984 18.761C5.89984 17.1336 4.58065 15.8145 2.95334 15.8145C1.32603 15.8145 0.00683594 17.1336 0.00683594 18.761C0.00683594 20.3883 1.32603 21.7075 2.95334 21.7075Z"
fill="#EB5757"
/>
<path
d="M28.4379 4.21792H10.686C10.5167 4.2261 10.3476 4.19983 10.1888 4.14069C10.03 4.08156 9.88488 3.9908 9.76221 3.87392C9.63954 3.75703 9.54188 3.61646 9.47516 3.46071C9.40843 3.30496 9.37402 3.13728 9.37402 2.96784C9.37402 2.7984 9.40843 2.63073 9.47516 2.47498C9.54188 2.31923 9.63954 2.17865 9.76221 2.06177C9.88488 1.94488 10.03 1.85413 10.1888 1.79499C10.3476 1.73586 10.5167 1.70959 10.686 1.71777H28.4379C28.759 1.73328 29.0618 1.87176 29.2836 2.1045C29.5054 2.33723 29.629 2.64637 29.629 2.96784C29.629 3.28931 29.5054 3.59846 29.2836 3.83119C29.0618 4.06393 28.759 4.2024 28.4379 4.21792Z"
fill="currentColor"
/>
<path
d="M25.0217 12.0514H10.686C10.5167 12.0596 10.3476 12.0333 10.1888 11.9742C10.03 11.9151 9.88488 11.8243 9.76221 11.7074C9.63954 11.5905 9.54188 11.45 9.47516 11.2942C9.40843 11.1385 9.37402 10.9708 9.37402 10.8013C9.37402 10.6319 9.40843 10.4642 9.47516 10.3085C9.54188 10.1527 9.63954 10.0121 9.76221 9.89526C9.88488 9.77838 10.03 9.68762 10.1888 9.62849C10.3476 9.56936 10.5167 9.54309 10.686 9.55126H25.0217C25.3428 9.56678 25.6456 9.70526 25.8674 9.93799C26.0892 10.1707 26.2129 10.4799 26.2129 10.8013C26.2129 11.1228 26.0892 11.432 25.8674 11.6647C25.6456 11.8974 25.3428 12.0359 25.0217 12.0514Z"
fill="currentColor"
/>
<path
d="M31.6878 19.9689H10.683C10.5138 19.9771 10.3447 19.9508 10.1859 19.8917C10.0271 19.8325 9.88195 19.7418 9.75928 19.6249C9.63661 19.508 9.53895 19.3674 9.47223 19.2117C9.4055 19.0559 9.37109 18.8883 9.37109 18.7188C9.37109 18.5494 9.4055 18.3817 9.47223 18.226C9.53895 18.0702 9.63661 17.9296 9.75928 17.8127C9.88195 17.6959 10.0271 17.6051 10.1859 17.546C10.3447 17.4868 10.5138 17.4606 10.683 17.4687H31.6878C31.8571 17.4606 32.0262 17.4868 32.185 17.546C32.3438 17.6051 32.4889 17.6959 32.6116 17.8127C32.7342 17.9296 32.8319 18.0702 32.8986 18.226C32.9654 18.3817 32.9998 18.5494 32.9998 18.7188C32.9998 18.8883 32.9654 19.0559 32.8986 19.2117C32.8319 19.3674 32.7342 19.508 32.6116 19.6249C32.4889 19.7418 32.3438 19.8325 32.185 19.8917C32.0262 19.9508 31.8571 19.9771 31.6878 19.9689Z"
fill="currentColor"
/>
<path
d="M27.271 27.8864H10.686C10.5167 27.8946 10.3476 27.8683 10.1888 27.8092C10.03 27.75 9.88488 27.6593 9.76221 27.5424C9.63954 27.4255 9.54188 27.2849 9.47516 27.1292C9.40843 26.9734 9.37402 26.8057 9.37402 26.6363C9.37402 26.4669 9.40843 26.2992 9.47516 26.1434C9.54188 25.9877 9.63954 25.8471 9.76221 25.7302C9.88488 25.6133 10.03 25.5226 10.1888 25.4635C10.3476 25.4043 10.5167 25.378 10.686 25.3862H27.271C27.5921 25.4017 27.8949 25.5402 28.1167 25.773C28.3384 26.0057 28.4621 26.3148 28.4621 26.6363C28.4621 26.9578 28.3384 27.2669 28.1167 27.4996C27.8949 27.7324 27.5921 27.8709 27.271 27.8864Z"
fill="currentColor"
/>
</svg>
<div
className="dialog bottom left"
>
<div>
<span>
<div
className="color orange"
/>
</span>
<span>
mapLegend.no
</span>
</div>
<div>
<span>
<div
className="color red"
/>
</span>
<span>
mapLegend.partial
</span>
</div>
<div>
<span>
<div
className="color orange"
/>
</span>
<span>
mapLegend.full
</span>
</div>
<div>
<span>
<div
className="color green"
/>
</span>
<span>
mapLegend.noData
</span>
</div>
</div>
</legend>
`;

exports[`renders correctly when there are no items 1`] = `
<legend
className="btn "
dark="false"
ii8n={[Function]}
onClick={[Function]}
style={
Object {
"cursor": "pointer",
}
}
t={[Function]}
tab="dailyLife"
type="legend"
Expand Down