Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ts-node so you can easily debug in webstorm * update test to include overridden method * add failing test using imported external aspect * add comment * add external advice test
- Loading branch information
1 parent
97bf62a
commit 79c21d1
Showing
6 changed files
with
175 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
Wove, | ||
resetRegistry | ||
} from '../../lib/src/core'; | ||
|
||
import { expect } from 'chai'; | ||
|
||
import './external_aspect' | ||
|
||
describe('sync advices', () => { | ||
afterEach(() => { | ||
resetRegistry(); | ||
}); | ||
|
||
describe('External AroundAdvice', () => { | ||
it('should invoke the external advice with the appropriate metadata', () => { | ||
let demo: any; | ||
|
||
@Wove() | ||
class Demo { | ||
get(foo: any, bar: any): string { return 'Demo' } | ||
} | ||
|
||
demo = new Demo(); | ||
expect(demo.get(42, 1.618)).to.equal('ExternalAspect'); | ||
}); | ||
}); | ||
}); |
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,16 @@ | ||
import { aroundMethod, Metadata } from "../../lib"; | ||
import { expect } from "chai"; | ||
|
||
export default class ExternalAspect { | ||
@aroundMethod({ classNamePattern: /.*/, methodNamePattern: /.*/ }) | ||
around(metadata: Metadata) { | ||
expect(this).to.deep.equal(ExternalAspect.prototype); | ||
expect(metadata.className).to.equal('Demo'); | ||
expect(metadata.method.name).to.equal('get'); | ||
expect(metadata.method.args).to.deep.equal([42, 1.618]); | ||
expect(metadata.method.invoke).to.be.a('function'); | ||
|
||
metadata.method.proceed = false | ||
metadata.method.result = 'ExternalAspect' | ||
} | ||
} |
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