Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
84 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Wove, resetRegistry, Metadata } from '../../lib/src/core'; | ||
|
||
import { expect } from 'chai'; | ||
import { aroundMethod } from '../../lib'; | ||
|
||
describe('around advices', () => { | ||
it('should only get invoked once when using MethodMetadata.complete()', () => { | ||
let count = 0; | ||
|
||
class Aspect { | ||
@aroundMethod({ classNamePattern: /^Test/, methodNamePattern: /^get$/ }) | ||
aroundMethod(meta: Metadata) { | ||
return meta.method.complete(...meta.method.args) + ' appended from the aspect'; | ||
} | ||
} | ||
|
||
@Wove() | ||
class Test { | ||
get(it: string): string { | ||
count++; | ||
return it; | ||
} | ||
} | ||
|
||
const test = new Test(); | ||
expect(test.get('test')).to.equal('test appended from the aspect'); | ||
expect(count).to.equal(1); | ||
}); | ||
}); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { aroundMethod, Metadata } from "../../lib"; | ||
import { expect } from "chai"; | ||
import { aroundMethod, Metadata } from '../../lib'; | ||
import { expect } from 'chai'; | ||
|
||
export default class ExternalAspect { | ||
@aroundMethod({ classNamePattern: /.*/, methodNamePattern: /.*/ }) | ||
@aroundMethod({ classNamePattern: /^ExternalAspectDemo$/, methodNamePattern: /.*/ }) | ||
around(metadata: Metadata) { | ||
expect(this).to.deep.equal(ExternalAspect.prototype); | ||
expect(metadata.className).to.equal('Demo'); | ||
expect(metadata.className).to.equal('ExternalAspectDemo'); | ||
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' | ||
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
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