-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(asset-bundle): add "assetBundle asset node" and "load assetBundl…
…e" related test cases
- Loading branch information
Showing
16 changed files
with
521 additions
and
6 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
75 changes: 75 additions & 0 deletions
75
...mposable_component/header/__snapshots__/mainEditorAssetHeaderLoadAssetBundle_test.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,75 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MainEditorAssetHeader->load assetBundle test load asset bundle fix bug if load the same asset bundle in the same dir, should handle their name to be unique 1`] = ` | ||
<article | ||
className="wonder-asset-assetChildren" | ||
> | ||
<article | ||
className="wonder-asset-fileBox " | ||
onClick={[Function]} | ||
> | ||
<div | ||
className="box-image" | ||
> | ||
<img | ||
onDragStart={[Function]} | ||
src="./public/img/assetBundle.png" | ||
/> | ||
</div> | ||
<div | ||
className="item-text " | ||
> | ||
<span> | ||
A | ||
</span> | ||
</div> | ||
</article> | ||
<article | ||
className="wonder-asset-fileBox " | ||
onClick={[Function]} | ||
> | ||
<div | ||
className="box-image" | ||
> | ||
<img | ||
onDragStart={[Function]} | ||
src="./public/img/assetBundle.png" | ||
/> | ||
</div> | ||
<div | ||
className="item-text " | ||
> | ||
<span> | ||
A 1 | ||
</span> | ||
</div> | ||
</article> | ||
</article> | ||
`; | ||
|
||
exports[`MainEditorAssetHeader->load assetBundle test load asset bundle should add to asset children 1`] = ` | ||
<article | ||
className="wonder-asset-assetChildren" | ||
> | ||
<article | ||
className="wonder-asset-fileBox " | ||
onClick={[Function]} | ||
> | ||
<div | ||
className="box-image" | ||
> | ||
<img | ||
onDragStart={[Function]} | ||
src="./public/img/assetBundle.png" | ||
/> | ||
</div> | ||
<div | ||
className="item-text " | ||
> | ||
<span> | ||
A | ||
</span> | ||
</div> | ||
</article> | ||
</article> | ||
`; |
10 changes: 10 additions & 0 deletions
10
...osable_component/header/__snapshots__/mainEditorAssetHeaderRemoveAssetBundle_test.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,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MainEditorAssetHeader->remove assetBundle | ||
select assetBundle; | ||
click remove-button; | ||
should remove it from assetTreeRoot 1`] = ` | ||
<article | ||
className="wonder-asset-assetChildren" | ||
/> | ||
`; |
71 changes: 71 additions & 0 deletions
71
...ntegration/asset/composable_component/header/mainEditorAssetHeaderLoadAssetBundle_test.re
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,71 @@ | ||
open Wonder_jest; | ||
|
||
open Expect; | ||
|
||
open Expect.Operators; | ||
|
||
open Sinon; | ||
|
||
open Js.Promise; | ||
|
||
let _ = | ||
describe("MainEditorAssetHeader->load assetBundle", () => { | ||
let sandbox = getSandboxDefaultVal(); | ||
|
||
beforeEach(() => { | ||
sandbox := createSandbox(); | ||
|
||
MainEditorSceneTool.initState(~sandbox, ()); | ||
MainEditorAssetTool.buildFakeFileReader(); | ||
}); | ||
|
||
afterEach(() => restoreSandbox(refJsObjToSandbox(sandbox^))); | ||
|
||
describe("test load asset bundle", () => { | ||
testPromise("should add to asset children", () => | ||
MainEditorAssetUploadTool.loadOneAssetBundle(~fileName="A.rab", ()) | ||
|> then_(uploadedAssetBundleNodeId => | ||
BuildComponentTool.buildAssetChildrenNode() | ||
|> ReactTestTool.createSnapshotAndMatch | ||
|> resolve | ||
) | ||
); | ||
|
||
testPromise("should store assetBundle arrayBuffer", () => { | ||
let assetBundle = Js.Typed_array.ArrayBuffer.make(20); | ||
|
||
MainEditorAssetUploadTool.loadOneAssetBundle( | ||
~fileName="A.rab", | ||
~assetBundle, | ||
(), | ||
) | ||
|> then_(uploadedAssetBundleNodeId => | ||
MainEditorAssetAssetBundleNodeTool.getAssetBundle( | ||
uploadedAssetBundleNodeId, | ||
) | ||
|> StateLogicService.getEditorState | ||
|> expect == assetBundle | ||
|> resolve | ||
); | ||
}); | ||
|
||
describe("fix bug", () => | ||
testPromise( | ||
"if load the same asset bundle in the same dir, should handle their name to be unique", | ||
() => | ||
MainEditorAssetUploadTool.loadOneAssetBundle(~fileName="A.rab", ()) | ||
|> then_(uploadedAssetBundleNodeId => | ||
MainEditorAssetUploadTool.loadOneAssetBundle( | ||
~fileName="A.rab", | ||
(), | ||
) | ||
|> then_(uploadedAssetBundleNodeId => | ||
BuildComponentTool.buildAssetChildrenNode() | ||
|> ReactTestTool.createSnapshotAndMatch | ||
|> resolve | ||
) | ||
) | ||
) | ||
); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
...egration/asset/composable_component/header/mainEditorAssetHeaderRemoveAssetBundle_test.re
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 @@ | ||
open Wonder_jest; | ||
|
||
open Expect; | ||
|
||
open Expect.Operators; | ||
|
||
open Sinon; | ||
|
||
open Js.Promise; | ||
|
||
let _ = | ||
describe("MainEditorAssetHeader->remove assetBundle", () => { | ||
let sandbox = getSandboxDefaultVal(); | ||
|
||
beforeEach(() => { | ||
sandbox := createSandbox(); | ||
MainEditorSceneTool.initState(~sandbox, ()); | ||
MainEditorAssetTool.buildFakeFileReader(); | ||
}); | ||
|
||
afterEach(() => restoreSandbox(refJsObjToSandbox(sandbox^))); | ||
|
||
describe( | ||
{| | ||
select assetBundle; | ||
click remove-button; | ||
|}, | ||
() => | ||
testPromise("should remove it from assetTreeRoot", () => | ||
MainEditorAssetUploadTool.loadOneAssetBundle() | ||
|> then_(uploadedAssetBundleNodeId => { | ||
MainEditorAssetHeaderOperateNodeTool.removeAssetBundleNode( | ||
~assetBundleNodeId=uploadedAssetBundleNodeId, | ||
(), | ||
); | ||
|
||
BuildComponentTool.buildAssetChildrenNode() | ||
|> ReactTestTool.createSnapshotAndMatch | ||
|> resolve; | ||
}) | ||
) | ||
); | ||
}); |
10 changes: 10 additions & 0 deletions
10
test/integration/asset/tool/MainEditorAssetAssetBundleNodeTool.re
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,10 @@ | ||
let getName = (nodeId, editorState) => | ||
AssetBundleNodeAssetService.getNodeName( | ||
OperateTreeAssetEditorService.unsafeFindNodeById(nodeId, editorState) | ||
|> AssetBundleNodeAssetService.getNodeData, | ||
); | ||
|
||
let getAssetBundle = (nodeId, editorState) => | ||
AssetBundleNodeAssetService.getAssetBundle( | ||
OperateTreeAssetEditorService.unsafeFindNodeById(nodeId, editorState), | ||
); |
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
Oops, something went wrong.