-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复依赖,把hry-types放到peer中
- Loading branch information
Showing
38 changed files
with
420 additions
and
186 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,4 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": {} | ||
} |
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,50 @@ | ||
import simulate from "miniprogram-simulate"; | ||
import path from "path"; | ||
import { instanceConfig } from "../../../src"; | ||
import { BBeforeCreate } from "../../../src/behaviors/BbeforeCreated"; | ||
import { BComputedAndWatch } from "../../../src/behaviors/BComputedAndWatch"; | ||
import { BStore } from "../../../src/behaviors/BStore"; | ||
export const checkData = { | ||
options: {} as object | undefined, | ||
data: {} as any, | ||
behaviors: [] as string[], | ||
}; | ||
|
||
const behavior = Behavior({}); | ||
|
||
// 注入options配置 | ||
// @ts-ignore | ||
instanceConfig.setInjectInfo({ | ||
options: { | ||
addGlobalClass: true, | ||
multipleSlots: true, | ||
pureDataPattern: /^_/, | ||
virtualHost: true, | ||
}, | ||
data: { | ||
injectStr: "string", | ||
}, | ||
behaviors: [behavior], | ||
}); | ||
|
||
describe("inject数据被组件数据覆盖", () => { | ||
const id = simulate.load(path.resolve(__dirname, "duplicate")); | ||
const comp = simulate.render(id); | ||
const parent = document.createElement("parent-wrapper"); | ||
|
||
comp.attach(parent); | ||
|
||
test("注入options、data、behaviors", () => { | ||
expect(checkData.options).toStrictEqual({ | ||
classPrefix: "main", // miniprogram-simulate 定义的 | ||
addGlobalClass: false, | ||
multipleSlots: false, | ||
pureDataPattern: /^__/, | ||
virtualHost: false, | ||
}); | ||
|
||
expect(checkData.data.injectStr).toBe("changed"); | ||
|
||
expect(checkData.behaviors).toStrictEqual([BStore, BComputedAndWatch, behavior, BBeforeCreate]); | ||
}); | ||
}); |
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,28 @@ | ||
import { DefineComponent, RootComponent } from "../../../src"; | ||
import { checkData } from "./duplicate.test"; | ||
|
||
const rootComponent = RootComponent()({ | ||
options: { | ||
addGlobalClass: false, | ||
multipleSlots: false, | ||
pureDataPattern: /^__/, | ||
virtualHost: false, | ||
}, | ||
data: { | ||
injectStr: "changed", | ||
}, | ||
lifetimes: { | ||
beforeCreate(opt) { | ||
checkData.options = opt.options; | ||
|
||
checkData.data = opt.data; | ||
|
||
checkData.behaviors = opt.behaviors; | ||
}, | ||
}, | ||
}); | ||
|
||
DefineComponent({ | ||
name: "injectNormal", | ||
rootComponent, | ||
}); |
Empty file.
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,4 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": {} | ||
} |
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,44 @@ | ||
import simulate from "miniprogram-simulate"; | ||
import path from "path"; | ||
import { instanceConfig } from "../../../src"; | ||
|
||
export const checkData = { | ||
options: {} as object | undefined, | ||
data: {} as any, | ||
}; | ||
|
||
const options = { | ||
addGlobalClass: true, | ||
multipleSlots: true, | ||
pureDataPattern: /^_/, | ||
virtualHost: true, | ||
}; | ||
|
||
// 注入options配置 | ||
// @ts-ignore | ||
instanceConfig.setInjectInfo({ | ||
options, | ||
data: { | ||
injectStr: "string", | ||
}, | ||
store: { | ||
injectTheme: () => "dark", | ||
}, | ||
}); | ||
|
||
describe("inject-无重复", () => { | ||
const id = simulate.load(path.resolve(__dirname, "normal")); | ||
const comp = simulate.render(id); | ||
const parent = document.createElement("parent-wrapper"); | ||
|
||
comp.attach(parent); | ||
|
||
test("注入options、data、store", () => { | ||
expect(checkData.options).toStrictEqual({ | ||
classPrefix: "main", // miniprogram-simulate 定义的 | ||
...options, | ||
}); | ||
|
||
expect(checkData.data).toStrictEqual({ injectTheme: "dark", injectStr: "string" }); | ||
}); | ||
}); |
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 @@ | ||
import { DefineComponent, RootComponent } from "../../../src"; | ||
import { checkData } from "./normal.test"; | ||
|
||
const rootComponent = RootComponent()({ | ||
lifetimes: { | ||
beforeCreate(opt) { | ||
checkData.options = opt.options!; | ||
|
||
checkData.data = opt.data; | ||
}, | ||
}, | ||
}); | ||
|
||
DefineComponent({ | ||
name: "injectNormal", | ||
rootComponent, | ||
}); |
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.