Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Thirdeye
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Koishi Thirdeye
Commits
972cb6dd
Commit
972cb6dd
authored
May 03, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests
parent
d6abd9f7
Pipeline
#12263
passed with stages
in 2 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
tests/multi-instance.spec.ts
tests/multi-instance.spec.ts
+35
-2
No files found.
tests/multi-instance.spec.ts
View file @
972cb6dd
...
...
@@ -3,7 +3,7 @@ import { RegisterSchema, SchemaProperty } from 'schemastery-gen';
import
{
BasePlugin
}
from
'
../src/base-plugin
'
;
import
{
UseCommand
}
from
'
koishi-decorators
'
;
import
{
MultiInstancePlugin
}
from
'
../src/multi-plugin
'
;
import
{
App
}
from
'
koishi
'
;
import
{
App
,
Schema
}
from
'
koishi
'
;
class
MessageConfig
{
@
SchemaProperty
()
...
...
@@ -28,6 +28,14 @@ class Inner extends BasePlugin<InnerMessageConfig> {
}
}
@
DefinePlugin
({
schema
:
Schema
.
object
({
msg
:
Schema
.
string
()
})
})
class
Inner2
extends
BasePlugin
<
InnerMessageConfig
>
{
@
UseCommand
(
'
message
'
)
async
onMessage
()
{
return
this
.
config
.
msg
;
}
}
@
DefinePlugin
()
class
Outer
extends
MultiInstancePlugin
(
Inner
,
OuterMessageConfig
)
{
@
UseCommand
(
'
message2
'
)
...
...
@@ -41,8 +49,21 @@ class Outer extends MultiInstancePlugin(Inner, OuterMessageConfig) {
}
}
@
DefinePlugin
()
class
Outer2
extends
MultiInstancePlugin
(
Inner2
,
OuterMessageConfig
)
{
@
UseCommand
(
'
message2
'
)
async
onMessage
()
{
return
this
.
config
.
getMsg
();
}
@
UseCommand
(
'
message3
'
)
async
onInnerMessage
()
{
return
this
.
instances
[
0
].
config
.
msg
;
}
}
describe
(
'
It should register multi plugin instance
'
,
()
=>
{
it
(
'
register command on conditio
n
'
,
async
()
=>
{
it
(
'
should work on schemastery-ge
n
'
,
async
()
=>
{
const
app
=
new
App
();
app
.
plugin
(
Outer
,
{
msg
:
'
hello
'
,
instances
:
[{
msg
:
'
world
'
}]
});
await
app
.
start
();
...
...
@@ -53,4 +74,16 @@ describe('It should register multi plugin instance', () => {
expect
(
await
outerCommand
.
execute
({})).
toBe
(
'
hello
'
);
expect
(
await
innerInnerCommand
.
execute
({})).
toBe
(
'
world
'
);
});
it
(
'
should work on common schemastery
'
,
async
()
=>
{
const
app
=
new
App
();
app
.
plugin
(
Outer2
,
{
msg
:
'
hello
'
,
instances
:
[{
msg
:
'
world
'
}]
});
await
app
.
start
();
const
innerCommand
=
app
.
command
(
'
message
'
);
const
outerCommand
=
app
.
command
(
'
message2
'
);
const
innerInnerCommand
=
app
.
command
(
'
message3
'
);
expect
(
await
innerCommand
.
execute
({})).
toBe
(
'
world
'
);
expect
(
await
outerCommand
.
execute
({})).
toBe
(
'
hello
'
);
expect
(
await
innerInnerCommand
.
execute
({})).
toBe
(
'
world
'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment