Skip to content

Commit

Permalink
fix: test/lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang740 committed Dec 28, 2018
1 parent b0a7680 commit a994f3a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ package-lock.json
*.d.ts
*.js.map
.vscode
!typings/**/*.d.ts
.nyc_output
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"egg-ts-helper": "^1.6.0",
"rimraf": "^2.6.2",
"supertest": "^3.0.0",
"tslint": "^5.9.1",
"tslint": "^5.12.0",
"tslint-config-egg": "^1.0.0",
"typescript": "^2.8.1"
},
Expand Down
32 changes: 20 additions & 12 deletions test/aspect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ describe('test/aspect.test.js', () => {

it('normal', () => {
let a: A;
// tslint:disable-next-line
let isBefore = false;
// tslint:disable-next-line
let isAfter = false;
const order: string[] = [];

Expand All @@ -31,7 +33,7 @@ describe('test/aspect.test.js', () => {
},
after: context => {
order.push('3');
after = true;
isAfter = true;
assert.equal(context.inst, a);
assert.equal(context.ret, 'a:test');
},
Expand All @@ -46,28 +48,28 @@ describe('test/aspect.test.js', () => {
order.push('0');
a.method('test');
order.push('4');
assert.equal(before, true);
assert.equal(after, true);
assert.equal(isBefore, true);
assert.equal(isAfter, true);
assert.deepEqual(order, [ '0', '1', '2', '3', '4' ]);
});

it('async', async () => {
let a: A;
let before = false;
let after = false;
let isBefore = false;
let isAfter = false;
const order: string[] = [];

function test() {
return aspect({
before: context => {
order.push('1');
before = true;
isBefore = true;
assert.equal(context.inst, a);
assert.deepEqual(context.args, [ 'test' ]);
},
after: context => {
order.push('3');
after = true;
isAfter = true;
assert.equal(context.inst, a);
assert.equal(context.ret, 'a:test');
},
Expand All @@ -86,8 +88,8 @@ describe('test/aspect.test.js', () => {
order.push('0');
await a.method('test');
order.push('4');
assert.equal(before, true);
assert.equal(after, true);
assert.equal(isBefore, true);
assert.equal(isAfter, true);
assert.deepEqual(order, [ '0', '1', '2', '3', '4' ]);
});

Expand Down Expand Up @@ -133,7 +135,8 @@ describe('test/aspect.test.js', () => {

it('throw error', () => {
let a: A;
const error = false;
// tslint:disable-next-line
let error = false;

class A {
@aspect({
Expand All @@ -154,7 +157,8 @@ describe('test/aspect.test.js', () => {

it('async, throw error', async () => {
let a: A;
const error = false;
// tslint:disable-next-line
let error = false;

class A {
@aspect({
Expand Down Expand Up @@ -224,7 +228,11 @@ describe('test/aspect.test.js', () => {
const testErr = new Error('test');

class A {
@aspect()
@aspect({
error: ctx => {
ctx.err = testErr;
},
})
method(a: string) {
throw new Error(a);
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"module": "commonjs",
"jsx": "react",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitAny": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"preserveConstEnums": true,
"declaration": true,
"sourceMap": false,
"pretty": true,
"noUnusedLocals": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"importHelpers": false
},
Expand Down

0 comments on commit a994f3a

Please sign in to comment.