1 | "use strict";
|
2 |
|
3 | const recaptcha = require('./recaptcha');
|
4 |
|
5 |
|
6 |
|
7 | const publicKey = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI';
|
8 | const privateKey = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe';
|
9 |
|
10 | describe('recaptcha', function ()
|
11 | {
|
12 |
|
13 |
|
14 | it(`should not restrict if settings are not present 1`, function (done)
|
15 | {
|
16 | recaptcha()(null, null, done)
|
17 | });
|
18 |
|
19 | it(`should not restrict if settings are not present 2`, function (done)
|
20 | {
|
21 | recaptcha({})(null, null, done)
|
22 | });
|
23 |
|
24 | it(`should not restrict if settings are not present 3`, function (done)
|
25 | {
|
26 | recaptcha({
|
27 | publicKey
|
28 | })(null, null, done)
|
29 | });
|
30 |
|
31 | it(`should not restrict if settings are not present 4`, function (done)
|
32 | {
|
33 | recaptcha({
|
34 | privateKey
|
35 | })(null, null, done)
|
36 | });
|
37 |
|
38 | it(`should not restrict if everything is peachy`, function (done)
|
39 | {
|
40 | recaptcha({
|
41 | publicKey,
|
42 | privateKey
|
43 | })({
|
44 | body: {
|
45 | recaptchaResponse: 'test'
|
46 | }
|
47 | }, null, done)
|
48 | });
|
49 |
|
50 | it(`should restrict if body is not present`, function (done)
|
51 | {
|
52 | recaptcha({
|
53 | publicKey,
|
54 | privateKey
|
55 | })({
|
56 | body: {}
|
57 | }, {
|
58 | error: () => done()
|
59 | }, null)
|
60 | });
|
61 |
|
62 | it(`should restrict if validation fails`, function (done)
|
63 | {
|
64 | recaptcha({
|
65 | publicKey,
|
66 | privateKey: privateKey + 'xx'
|
67 | })({
|
68 | body: {
|
69 | recaptchaResponse: 'test'
|
70 | }
|
71 | }, {
|
72 | error: () => done()
|
73 | }, null)
|
74 | });
|
75 |
|
76 | })
|