-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4191849
commit fda3b02
Showing
3 changed files
with
57 additions
and
28 deletions.
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
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 |
---|---|---|
@@ -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> | ||
`)}); |