-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(platform): assemble_space : begin test Publish
add useState to service; note: test Modal snapshot error: parentInstance.children.indexOf is not a function refer to: reactjs/react-modal#553 https://medium.com/@amanverma.dev/mocking-create-portal-to-utilize-react-test-renderer-in-writing-snapshot-uts-c49773c88acd this is react-test-renderer's bug that the Modal use createPortal and cause the error! so not test Modal snapshot!
- Loading branch information
Showing
10 changed files
with
133 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Feature: Publish | ||
As a Publish | ||
I want to publish app | ||
So that I can use it | ||
|
||
Background: prepare | ||
Given prepare sandbox | ||
And prepare snapshot | ||
|
||
Scenario: show publish button | ||
When render Publish | ||
Then should show publish button | ||
|
||
# Scenario: show modal after click publish button | ||
# When render Publish | ||
# And click publish button | ||
# Then should show modal |
14 changes: 14 additions & 0 deletions
14
platform/assemble-space/test/step-definitions/__snapshots__/publish.steps.bs.js.snap
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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Publish show publish button 1`] = ` | ||
<button | ||
className="ant-btn ant-btn-default" | ||
disabled={false} | ||
onClick={[Function]} | ||
type="button" | ||
> | ||
<span> | ||
发 布 | ||
</span> | ||
</button> | ||
`; |
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,82 @@ | ||
open Meta3dBsJestCucumber | ||
open Cucumber | ||
open Expect | ||
open Operators | ||
|
||
open Sinon | ||
|
||
let feature = loadFeature("./test/features/publish.feature") | ||
|
||
defineFeature(feature, test => { | ||
let sandbox = ref(Obj.magic(1)) | ||
|
||
// let _prepare = (given, \"and", initialState, store) => { | ||
let _prepare = (given, \"and") => { | ||
given("prepare sandbox", () => { | ||
sandbox := createSandbox() | ||
}) | ||
|
||
\"and"("prepare snapshot", () => { | ||
ReactTestTool.prepare() | ||
}) | ||
} | ||
|
||
test(."show publish button", ({given, \"when", \"and", then}) => { | ||
_prepare(given, \"and") | ||
|
||
\"when"("render Publish", () => { | ||
() | ||
}) | ||
|
||
then("should show publish button", () => { | ||
PublishTool.buildUI( | ||
~sandbox, | ||
~service=ServiceTool.build( | ||
~sandbox, | ||
~useSelector=createEmptyStub(refJsObjToSandbox(sandbox.contents))->returns( | ||
(list{}, list{}), | ||
_, | ||
), | ||
(), | ||
), | ||
(), | ||
) | ||
->ReactTestRenderer.create | ||
->ReactTestTool.createSnapshotAndMatch | ||
}) | ||
}) | ||
|
||
// test(."show modal after click publish button", ({given, \"when", \"and", then}) => { | ||
// _prepare(given, \"and") | ||
|
||
// \"when"("render Publish", () => { | ||
// () | ||
// }) | ||
|
||
// \"and"("click publish button", () => { | ||
// () | ||
// }) | ||
|
||
// then("should show modal", () => { | ||
// let component = | ||
// PublishTool.buildUI( | ||
// ~sandbox, | ||
// ~service=ServiceTool.build( | ||
// ~sandbox, | ||
// ~useState=createEmptyStub(refJsObjToSandbox(sandbox.contents))->returns( | ||
// (true, _ => true), | ||
// _, | ||
// ), | ||
// ~useSelector=createEmptyStub(refJsObjToSandbox(sandbox.contents))->returns( | ||
// (list{}, list{}), | ||
// _, | ||
// ), | ||
// (), | ||
// ), | ||
// (), | ||
// ) | ||
// ->ReactTestRenderer.create | ||
// ->ReactTestTool.createSnapshotAndMatch | ||
// }) | ||
// }) | ||
}) |
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,3 @@ | ||
let buildUI = (~sandbox, ~username=None, ~service=ServiceTool.build(~sandbox, ()), ()) => { | ||
<Publish service username /> | ||
} |
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