Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
cordis-decorators
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
cordis-decorators
Commits
c0ed61e6
Commit
c0ed61e6
authored
Jul 18, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more unit tests
parent
b276ec6b
Pipeline
#14633
failed with stages
in 1 minute and 10 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
src/registrar-aspect.ts
src/registrar-aspect.ts
+3
-2
src/registrar.ts
src/registrar.ts
+1
-0
tests/using.spec.ts
tests/using.spec.ts
+37
-0
No files found.
src/registrar-aspect.ts
View file @
c0ed61e6
...
...
@@ -56,12 +56,13 @@ export class RegistrarAspect<Ctx extends Context, T = any> {
):
Registrar
.
RegisterResult
<
Ctx
,
T
>
{
const
data
=
this
.
registrar
.
reflector
.
get
(
'
CordisRegister
'
,
this
.
obj
,
key
);
if
(
!
data
)
return
;
const
specificCtx
=
this
.
getScopeContext
(
ctx
,
key
,
extraView
,
false
);
const
result
=
data
.
action
(
this
.
getScopeContext
(
ctx
,
key
,
extraView
,
false
)
,
specificCtx
,
extractObjectMethod
(
this
.
obj
,
key
),
...
renderObject
(
data
.
args
,
{
...
this
.
view
,
...
extraView
}),
);
return
{
...
data
,
key
:
key
,
result
};
return
{
...
data
,
key
:
key
,
result
,
ctx
:
specificCtx
};
}
private
registerWithLoopControl
(
...
...
src/registrar.ts
View file @
c0ed61e6
...
...
@@ -79,6 +79,7 @@ export namespace Registrar {
>
extends
RegisterInfo
<
C
>
{
key
:
keyof
T
&
string
;
result
:
MethodReturn
<
C
,
K
>
;
ctx
:
C
;
}
export
interface
ProvideOptions
extends
Context
.
ServiceOptions
{
...
...
tests/using.spec.ts
0 → 100644
View file @
c0ed61e6
import
{
DefinePlugin
,
StarterPlugin
,
UseEvent
}
from
'
./utility/decorators
'
;
import
{
Provide
,
UsingService
}
from
'
../src/decorators
'
;
import
{
Context
}
from
'
cordis
'
;
declare
module
'
cordis
'
{
interface
Events
<
C
>
{
foo
():
string
;
}
}
@
Provide
(
'
foo
'
)
@
DefinePlugin
()
class
MyProvider
extends
StarterPlugin
()
{}
@
DefinePlugin
()
class
MyPlugin
extends
StarterPlugin
()
{
@
UsingService
(
'
foo
'
)
@
UseEvent
(
'
foo
'
)
onFoo
()
{
return
'
bar
'
;
}
}
describe
(
'
Partial using service
'
,
()
=>
{
it
(
'
should trigger when available
'
,
async
()
=>
{
const
app
=
new
Context
();
await
app
.
start
();
app
.
plugin
(
MyPlugin
);
expect
(
app
.
bail
(
'
foo
'
)).
toBeUndefined
();
const
state
=
app
.
plugin
(
MyProvider
);
expect
(
app
.
bail
(
'
foo
'
)).
toBe
(
'
bar
'
);
state
.
dispose
();
expect
(
app
.
bail
(
'
foo
'
)).
toBeUndefined
();
app
.
plugin
(
MyProvider
);
expect
(
app
.
bail
(
'
foo
'
)).
toBe
(
'
bar
'
);
});
});
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