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
6e8f8f0
commit e63c41d
Showing
10 changed files
with
168 additions
and
36 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,4 +1,4 @@ | ||
class SavedGarden < ApplicationRecord | ||
belongs_to :device | ||
has_many :plant_templates | ||
has_many :plant_templates, dependent: :destroy | ||
end |
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
32 changes: 32 additions & 0 deletions
32
webpack/farm_designer/saved_gardens/__tests__/garden_list_test.tsx
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,32 @@ | ||
jest.mock("../actions", () => ({ | ||
openOrCloseGarden: jest.fn(), | ||
})); | ||
|
||
jest.mock("../../../api/crud", () => ({ | ||
edit: jest.fn(), | ||
save: jest.fn(), | ||
})); | ||
|
||
import * as React from "react"; | ||
import { shallow } from "enzyme"; | ||
import { | ||
fakeSavedGarden | ||
} from "../../../__test_support__/fake_state/resources"; | ||
import { edit } from "../../../api/crud"; | ||
import { GardenInfo } from "../garden_list"; | ||
|
||
describe("<GardenInfo />", () => { | ||
const fakeProps = () => ({ | ||
dispatch: jest.fn(), | ||
savedGarden: fakeSavedGarden(), | ||
gardenIsOpen: false, | ||
plantCount: 1, | ||
}); | ||
|
||
it("edits garden name", () => { | ||
const wrapper = shallow(<GardenInfo {...fakeProps()} />); | ||
wrapper.find("BlurableInput").simulate("commit", | ||
{ currentTarget: { value: "new name" } }); | ||
expect(edit).toHaveBeenCalledWith(expect.any(Object), { name: "new name" }); | ||
}); | ||
}); |
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