-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #347 from RickCarlino/master
Test Suite Updates
- Loading branch information
Showing
19 changed files
with
215 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## other configuration excluded from example... | ||
exclude_paths: | ||
- "public/app-resources/languages" | ||
- public/app-resources/languages/*.js |
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,43 @@ | ||
import { | ||
buildResourceIndex, | ||
FAKE_RESOURCES | ||
} from "../__test_support__/resource_index_builder"; | ||
import { betterCompact } from "../util"; | ||
import { TaggedFarmEvent } from "../resources/tagged_resources"; | ||
|
||
const STUB_RESOURCE: TaggedFarmEvent = { | ||
"uuid": "farm_events.0.435", | ||
"kind": "farm_events", | ||
"body": { | ||
"id": 217, | ||
"start_time": "2017-07-21T00:30:00.000Z", | ||
"end_time": "2017-07-21T00:31:00.000Z", | ||
"repeat": 1, | ||
"time_unit": "never", | ||
"executable_id": 78, | ||
"executable_type": "Regimen", | ||
"calendar": [ | ||
"2017-07-21T00:30:00.000Z" | ||
] | ||
} | ||
}; | ||
|
||
test("buildResourceIndex - base case", () => { | ||
let result1 = buildResourceIndex(FAKE_RESOURCES); | ||
let { index } = result1; | ||
const OK_LENGTH = FAKE_RESOURCES.length; | ||
expect(index.all.length).toBe(OK_LENGTH); | ||
expect(Object.keys(index.references).length).toBe(OK_LENGTH); | ||
}); | ||
|
||
test("buildResourceIndex - add a FarmEvent", () => { | ||
let db = buildResourceIndex([STUB_RESOURCE]); | ||
let fe = db.index.references[db.index.byKind.farm_events[0]]; | ||
expect(fe).toBeTruthy(); | ||
if (fe && fe.kind === "farm_events") { | ||
let { body } = fe; | ||
expect(body).toEqual(STUB_RESOURCE.body); | ||
} else { | ||
fail("fe was falsy or not a farm event."); | ||
} | ||
}); |
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
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,6 @@ | ||
import { list } from "../tz_list"; | ||
|
||
test("TZ List presence", () => { | ||
// Not the most useful test. Might catch accidental erasure, though. | ||
expect(list.length).toBe(588); | ||
}); |
112 changes: 112 additions & 0 deletions
112
src/farm_designer/farm_events/__tests__/map_state_to_props_test.ts
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,112 @@ | ||
import { fakeState } from "../../../__test_support__/fake_state"; | ||
import { mapResourcesToCalendar } from "../map_state_to_props"; | ||
import { ResourceIndex } from "../../../resources/interfaces"; | ||
import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; | ||
import { TaggedResource } from "../../../resources/tagged_resources"; | ||
import * as moment from "moment"; | ||
|
||
describe("mapResourcesToCalendar()", () => { | ||
it("returns a `Calendar` instance when given a resource index and unix time.", | ||
() => { | ||
pending(); | ||
// 19 JULY 17 16:30 | ||
const TWO_O_EIGHT = 1500664092110; | ||
let wow = fakeResources(); | ||
let ri = buildResourceIndex(wow); | ||
let results = mapResourcesToCalendar(ri.index, TWO_O_EIGHT).getAll(); | ||
expect(results.length).toBe(1); | ||
let item1 = results[0]; | ||
expect(item1.month).toBe("Jul"); | ||
expect(item1.day).toBe(17); | ||
}); | ||
}); | ||
|
||
function fakeResources(): TaggedResource[] { | ||
return [ | ||
{ | ||
"kind": "farm_events", | ||
"body": { | ||
"id": 76, | ||
"start_time": "2017-07-19T21:20:00.000", | ||
"end_time": "2017-07-21T20:57:00.000", | ||
"repeat": 1, | ||
"time_unit": "daily", | ||
"executable_id": 25, | ||
"executable_type": "Regimen", | ||
"calendar": [ | ||
|
||
] | ||
}, | ||
"uuid": "farm_events.76.2" | ||
}, | ||
{ | ||
"kind": "regimens", | ||
"body": { | ||
"id": 25, | ||
"name": "Every 4 hours", | ||
"color": "gray", | ||
"device_id": 49, | ||
"regimen_items": [ | ||
{ | ||
"id": 86, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 300000 | ||
}, | ||
{ | ||
"id": 87, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 14700000 | ||
}, | ||
{ | ||
"id": 88, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 29100000 | ||
}, | ||
{ | ||
"id": 89, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 43500000 | ||
}, | ||
{ | ||
"id": 90, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 57900000 | ||
}, | ||
{ | ||
"id": 91, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 50400000 | ||
}, | ||
{ | ||
"id": 92, | ||
"regimen_id": 25, | ||
"sequence_id": 52, | ||
"time_offset": 72000000 | ||
} | ||
] | ||
}, | ||
"uuid": "regimens.25.49" | ||
}, | ||
{ | ||
"kind": "sequences", | ||
"body": { | ||
"id": 52, | ||
"name": "Goto 0, 0, 0 123", | ||
"color": "gray", | ||
"body": [], | ||
"args": { | ||
"is_outdated": false, | ||
"version": 4 | ||
}, | ||
"kind": "sequence" | ||
}, | ||
"uuid": "sequences.52.52" | ||
} | ||
]; | ||
} |
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
Oops, something went wrong.