Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raven-wing authored Oct 4, 2022
1 parent 4191849 commit fda3b02
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# goodmap-frontend

Frontend for [GoodMap](https://github.com/Problematy/goodmap).
Frontend for [GoodMap](https://github.com/Problematy/goodmap)

# Installing

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@problematy/goodmap",
"version": "0.1.3",
"version": "0.1.4",
"description": "Fronted scripts for map ",
"main": "dist/map.js",
"scripts": {
Expand Down
81 changes: 55 additions & 26 deletions tests/map.test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,57 @@
import {createCheckboxWithType} from '../src/checkboxes.js'
import * as ReactDOMServer from 'react-dom/server';
import {createFilterForm} from '../src/filter_form.js'

//TODO: this test should not need rendering to string
test("Creates good checkbox box", async () => {
expect(
ReactDOMServer.renderToStaticMarkup(createCheckboxWithType("gender", "female", "kobieta")))
.toContain(
'<div class="form-check"><label for="female">kobieta</label><input class="form-check-input filter gender" type="checkbox" name="name" id="female" value="female"/></div>');
});
let categories = [
[
["types", "typy" ],
[
["clothes", "ciuchy"],
["shoes", "buty"]
]
]
]


// --------------------------------
import {getFormattedData} from '../src/formatters.js'
test("Formats data for popup well", async () => {
const fakeData = {
title: "test",
subtitle: "container",
data:{
types: ["clothes"],
gender: ["men"],
condition: ["worn"]
}
};
expect(getFormattedData(fakeData)).toBe(
'<div class="place-data"><p><b>test</b><br/>container</p><p><b>types</b>: clothes<br><b>gender</b>: men<br><b>condition</b>: worn</p></div>'
);
});
test("Creates good filter_form box", async () => {
expect(createFilterForm(categories, () => {})).
toMatchInlineSnapshot(`
<form>
<div>
<span
textcontent="types"
>
typy
</span>
<div
className="form-check"
onClick={[Function]}
>
<label
htmlFor="clothes"
>
ciuchy
</label>
<input
className="form-check-input filter types"
id="clothes"
type="checkbox"
value="clothes"
/>
</div>
<div
className="form-check"
onClick={[Function]}
>
<label
htmlFor="shoes"
>
buty
</label>
<input
className="form-check-input filter types"
id="shoes"
type="checkbox"
value="shoes"
/>
</div>
</div>
</form>
`)});

0 comments on commit fda3b02

Please sign in to comment.