-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
62 lines (55 loc) · 1.46 KB
/
Copy pathindex.test.js
File metadata and controls
62 lines (55 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { test } from 'tap';
import assert from 'supertest';
import fastify from 'fastify';
import plugin, {
Model, HashPassword,
GetIp, VerifyPassword,
FixMobile, MakeSearchQuery
} from './index.js';
process.env.NODE_ENV = 'test';
process.env.PAGE_TITLE = 'test';
process.env.ROUTE_PREFIX = 'test';
process.env.REDIS_CONNSTR = 'test';
process.env.POSTGRE_CONNSTR = 'test';
process.env.AWS_ACCESS_KEY_ID = 'test';
process.env.AWS_SECRET_ACCESS_KEY = 'test';
process.env.EMAIL_FROM = 'test';
process.env.EMAIL_REGION = 'test';
process.env.MOBILE_REGION = 'test';
process.env.RECAPTCHA_KEY = 'test';
process.env.CSRFCOOKIE_NAME = 'test';
process.env.UIDCOOKIE_NAME = 'test';
process.env.JWTCOOKIE_NAME = 'test';
test('runs when registered', async t => {
const app = fastify({
ignoreTrailingSlash: true,
trustProxy: true,
logger: true
});
await app.register(plugin, { privilegeCheck: true });
t.teardown(app.close.bind(app));
app.route({
method: 'GET',
path: '/',
handler: async (request, reply) => {
reply.send('ok');
}
});
t.ok(app.pbkdf2);
t.ok(app.getIp);
t.ok(app.fixMobile);
t.ok(app.makeSearchQuery);
t.ok(MakeSearchQuery);
t.ok(VerifyPassword);
t.ok(HashPassword);
t.ok(FixMobile);
t.ok(GetIp);
t.ok(Model);
const hashed = HashPassword('foobar');
t.ok(VerifyPassword('foobar', hashed));
t.notOk(VerifyPassword('bar', hashed));
await app.ready();
await assert(app.server)
.get('/')
.expect(200);
});