-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created date backed reading history and removed unused types * Move PageSelection out of Input * Full Day unit test coverage * Drop index.re from jest coverage, it's boilerplate from create-react-scripts
- Loading branch information
Showing
10 changed files
with
181 additions
and
47 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
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,33 @@ | ||
open PageType; | ||
open Types; | ||
open DokuUtil; | ||
|
||
module PageTypeSelection = { | ||
type inputState = { | ||
selection: pageType | ||
}; | ||
|
||
let str = ReasonReact.stringToElement; | ||
let component = ReasonReact.statelessComponent("PageTypeSelection"); | ||
|
||
let make = (~onChangeSelect, _) => { | ||
...component, | ||
render: (_) => { | ||
<select | ||
onChange=((evt) => { | ||
switch ( evt |> DokuUtil.valueFromEvent | ||
|> PageType.findOptType ) { | ||
| Some(pt) => | ||
onChangeSelect(pt); | ||
| None => () | ||
} | ||
})> | ||
((PageType.pageTypes |> | ||
List.map((pt: content) => | ||
<option key=pt.name value=pt.name>(str(pt.name))</option>) | ||
|> Array.of_list | ||
|> ReasonReact.arrayToElement)) | ||
</select> | ||
} | ||
}; | ||
}; |
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,40 @@ | ||
open Jest; | ||
|
||
open Day; | ||
|
||
describe("Day", () => { | ||
open Expect; | ||
|
||
describe("Day.today", () => { | ||
let today = Day.now(); | ||
test("Creates a day with no entries", () => | ||
expect(today.entries |> List.length) |> toBe(0)); | ||
|
||
test("Creates a string representation of a date time", () => | ||
expect(today.date |> String.length ) |> toBe(24)); | ||
}); | ||
|
||
describe("Day.yesterday", () => { | ||
let today = Day.yesterday(); | ||
test("Creates a day with no entries", () => | ||
expect(today.entries |> List.length) |> toBe(0)); | ||
|
||
test("Creates a string representation of a date time", () => | ||
expect(today.date |> String.length ) |> toBe(24)); | ||
}); | ||
|
||
|
||
describe("Day.entries", () => { | ||
let today = Day.now(); | ||
test("Is a helper method to get the Day's entry list", () => | ||
expect(today.entries) |> toEqual(Day.entries(today))); | ||
}); | ||
|
||
describe("Day.appendEntry", () => { | ||
let today = Day.now(); | ||
let appendedDay = Day.createEntry(1, News, 1) |> Day.appendEntry(today); | ||
test("Adds an entry to a day", () => | ||
expect(appendedDay.entries |> List.length) |> toBe(1)); | ||
}); | ||
|
||
}); |
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,23 @@ | ||
open Jest; | ||
|
||
open PageTypeSelection; | ||
|
||
describe("PageTypeSelection", () => { | ||
open ExpectJs; | ||
|
||
test("Renders when given an onChangeSelect function", () => { | ||
|
||
let onChangeSelectFunction = (pt) => (); | ||
|
||
let component = ReactShallowRenderer.renderWithRenderer( | ||
<PageTypeSelection onChangeSelect=onChangeSelectFunction/> | ||
); | ||
|
||
expect(Js.Undefined.return(component)) |> toBeDefined; | ||
}); | ||
|
||
describe("PageTypeSelection.str", () => { | ||
test("Is an alias for ReasonReact.stringToElement", () => | ||
expect(PageTypeSelection.str("Hello")) |> toBe(ReasonReact.stringToElement("Hello"))); | ||
}); | ||
}); |
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