Skip to content

Commit 42299f4

Browse files
committed
f
1 parent af085f0 commit 42299f4

12 files changed

Lines changed: 64 additions & 60 deletions

File tree

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
const mm = require('egg-mock');
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
describe('test/app/extends/cliFilter.test.js', () => {
4-
let app;
3+
describe('test/app/extends/cliFilter.test.ts', () => {
4+
let app: MockApplication;
55
before(() => {
66
app = mm.app({
77
baseDir: 'apps/helper-cliFilter-app',
8-
plugin: 'security',
98
});
109
return app.ready();
1110
});
1211

12+
after(() => app.close());
13+
1314
after(mm.restore);
1415

1516
describe('helper.cliFilter()', () => {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
const mm = require('egg-mock');
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
describe('test/app/extends/escapeShellArg.test.js', () => {
4-
let app;
3+
describe('test/app/extends/escapeShellArg.test.ts', () => {
4+
let app: MockApplication;
55
before(() => {
66
app = mm.app({
77
baseDir: 'apps/helper-escapeShellArg-app',
8-
plugin: 'security',
98
});
109
return app.ready();
1110
});
1211

12+
after(() => app.close());
13+
1314
after(mm.restore);
1415

1516
describe('helper.escapeShellArg()', () => {
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
const mm = require('egg-mock');
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
describe('test/app/extends/escapeShellCmd.test.js', () => {
4-
let app;
3+
describe('test/app/extends/escapeShellCmd.test.ts', () => {
4+
let app: MockApplication;
55
before(() => {
66
app = mm.app({
77
baseDir: 'apps/helper-escapeShellCmd-app',
8-
plugin: 'security',
98
});
109
return app.ready();
1110
});
1211

13-
after(mm.restore);
12+
after(() => app.close());
13+
14+
afterEach(mm.restore);
1415

1516
describe('helper.escapeShellCmd()', () => {
1617
it('should convert chars in blacklists', () => {
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
const { strict: assert } = require('node:assert');
2-
const mm = require('egg-mock');
1+
import { strict as assert } from 'node:assert';
2+
import { mm, MockApplication } from '@eggjs/mock';
33

4-
describe('test/app/extends/helper.test.js', () => {
5-
let app;
6-
let app2;
7-
let app3;
4+
describe('test/app/extends/helper.test.ts', () => {
5+
let app: MockApplication;
6+
let app2: MockApplication;
7+
let app3: MockApplication;
88
before(async () => {
99
app = mm.app({
1010
baseDir: 'apps/helper-app',
11-
plugin: 'security',
1211
});
1312
await app.ready();
1413

1514
app2 = mm.app({
1615
baseDir: 'apps/helper-config-app',
17-
plugin: 'security',
1816
});
1917
await app2.ready();
2018

2119
app3 = mm.app({
2220
baseDir: 'apps/helper-link-app',
23-
plugin: 'security',
2421
});
2522
await app3.ready();
2623
});
2724

28-
after(mm.restore);
25+
after(async () => {
26+
await app.close();
27+
await app2.close();
28+
await app3.close();
29+
});
30+
31+
afterEach(mm.restore);
2932

3033
describe('helper.escape()', () => {
3134
it('should work', () => {
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
const mm = require('egg-mock');
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
describe('test/app/extends/sjs.test.js', () => {
4-
let app;
3+
describe('test/app/extends/sjs.test.ts', () => {
4+
let app: MockApplication;
55
before(() => {
66
app = mm.app({
77
baseDir: 'apps/helper-sjs-app',
8-
plugin: 'security',
98
});
109
return app.ready();
1110
});
1211

13-
after(mm.restore);
12+
after(() => app.close());
13+
14+
afterEach(mm.restore);
1415

1516
describe('helper.sjs()', () => {
1617
it('should convert special chars on js context and not convert chart in whitelists', () => {
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
const mm = require('egg-mock');
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
describe('test/app/extends/sjson.test.js', () => {
4-
let app;
3+
describe('test/app/extends/sjson.test.ts', () => {
4+
let app: MockApplication;
55
before(() => {
66
app = mm.app({
77
baseDir: 'apps/helper-sjson-app',
8-
plugin: 'security',
98
});
109
return app.ready();
1110
});
1211

13-
after(mm.restore);
12+
after(() => app.close());
13+
14+
afterEach(mm.restore);
1415

1516
describe('helper.sjson()', () => {
1617
it('should not convert json string when json is safe', () => {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
const mm = require('egg-mock');
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
describe('test/app/extends/spath.test.js', () => {
4-
let app;
3+
describe('test/app/extends/spath.test.ts', () => {
4+
let app: MockApplication;
55
before(() => {
66
app = mm.app({
77
baseDir: 'apps/helper-spath-app',
8-
plugin: 'security',
98
});
109
return app.ready();
1110
});
1211

12+
after(() => app.close());
13+
1314
after(mm.restore);
1415

1516
describe('helper.spath()', () => {
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
const { strict: assert } = require('node:assert');
2-
const mm = require('egg-mock');
1+
import { strict as assert } from 'node:assert';
2+
import { mm, MockApplication } from '@eggjs/mock';
33

4-
describe('test/context.test.js', () => {
4+
describe('test/context.test.ts', () => {
55
afterEach(mm.restore);
6+
67
describe('context.isSafeDomain', () => {
7-
let app;
8+
let app: MockApplication;
89
before(() => {
910
app = mm.app({
1011
baseDir: 'apps/isSafeDomain-custom',
1112
});
1213
return app.ready();
1314
});
1415

16+
after(() => app.close());
17+
1518
it('should return false when domains are not safe', async () => {
1619
const res = await app.httpRequest()
1720
.get('/unsafe')
1821
.set('accept', 'text/html')
1922
.expect(200);
20-
assert(res.text === 'false');
23+
assert.equal(res.text, 'false');
2124
});
2225

2326
it('should return true when domains are safe', async () => {
2427
const res = await app.httpRequest()
2528
.get('/safe')
2629
.set('accept', 'text/html')
2730
.expect(200);
28-
assert(res.text === 'true');
31+
assert.equal(res.text, 'true');
2932
});
3033
});
3134
});
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
'use strict';
1+
import { mm, MockApplication } from '@eggjs/mock';
22

3-
const mm = require('egg-mock');
4-
5-
describe('test/csrf_cookieDomain.test.js', () => {
3+
describe('test/csrf_cookieDomain.test.ts', () => {
64
afterEach(mm.restore);
75

86
describe('cookieDomain = function', () => {
9-
let app;
7+
let app: MockApplication;
108
before(() => {
119
app = mm.app({
1210
baseDir: 'apps/ctoken',
@@ -26,7 +24,7 @@ describe('test/csrf_cookieDomain.test.js', () => {
2624
});
2725

2826
describe('cookieDomain = string', () => {
29-
let app;
27+
let app: MockApplication;
3028
before(() => {
3129
app = mm.app({
3230
baseDir: 'apps/csrf-string-cookiedomain',
@@ -46,7 +44,7 @@ describe('test/csrf_cookieDomain.test.js', () => {
4644
});
4745

4846
describe('cookieOptions = object', () => {
49-
let app;
47+
let app: MockApplication;
5048
before(() => {
5149
app = mm.app({
5250
baseDir: 'apps/csrf-cookieOptions',
@@ -66,7 +64,7 @@ describe('test/csrf_cookieDomain.test.js', () => {
6664
});
6765

6866
describe('cookieOptions use signed', () => {
69-
let app;
67+
let app: MockApplication;
7068
before(() => {
7169
app = mm.app({
7270
baseDir: 'apps/csrf-cookieOptions-signed',

‎test/fixtures/apps/csrf-cookieOptions/app/controller/home.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
2-
31
module.exports = app => {
42
return class Home extends app.Controller {
5-
* index() {
3+
async index() {
64
this.ctx.body = 'hello csrfToken cookieOptions';
75
}
86
};

0 commit comments

Comments
 (0)