|
1 | 1 | import React from "react"; |
2 | 2 | import ReactDOM from "react-dom"; |
3 | 3 | import ReactTestUtils from "react-addons-test-utils"; |
4 | | -import ReCAPTCHA from "../src/recaptcha"; |
| 4 | +import ReCAPTCHA from "../src/recaptcha"; // eslint-disable-line no-unused-vars |
5 | 5 |
|
6 | 6 | describe("ReCAPTCHA", () => { |
7 | 7 | it("Rendered Component should be a div", () => { |
8 | | - let instance = ReactTestUtils.renderIntoDocument( |
9 | | - <ReCAPTCHA sitekey="xxx" /> |
10 | | - ); |
| 8 | + const instance = ReactTestUtils.renderIntoDocument( |
| 9 | + <ReCAPTCHA sitekey="xxx" />, |
| 10 | + ); |
11 | 11 | assert.equal(ReactDOM.findDOMNode(instance).nodeName, "DIV"); |
12 | 12 | }); |
13 | 13 | it("Rendered Component should contained passed props", () => { |
14 | | - let props = { |
| 14 | + const props = { |
15 | 15 | className: "TheClassName", |
16 | 16 | id: "superdefinedId", |
17 | 17 | }; |
18 | | - let instance = ReactTestUtils.renderIntoDocument( |
19 | | - <ReCAPTCHA sitekey="xxx" {...props} /> |
20 | | - ); |
| 18 | + const instance = ReactTestUtils.renderIntoDocument( |
| 19 | + <ReCAPTCHA sitekey="xxx" {...props} />, |
| 20 | + ); |
21 | 21 | assert.equal(ReactDOM.findDOMNode(instance).id, props.id); |
22 | 22 | assert.match(ReactDOM.findDOMNode(instance).className, new RegExp(props.className)); |
23 | 23 | }); |
24 | 24 |
|
25 | 25 | it("should call grecaptcha.render, when it is already loaded", (done) => { |
26 | | - let grecaptchaMock = { |
27 | | - render(node, options) { |
| 26 | + const grecaptchaMock = { |
| 27 | + render (node, options) { |
28 | 28 | assert.isNotNull(node); |
29 | 29 | assert.equal(options.sitekey, "xxx"); |
30 | 30 | done(); |
31 | 31 | }, |
32 | 32 | }; |
33 | | - let instance = ReactTestUtils.renderIntoDocument( |
34 | | - <ReCAPTCHA sitekey="xxx" grecaptcha={grecaptchaMock} /> |
35 | | - ); |
| 33 | + const instance = ReactTestUtils.renderIntoDocument( |
| 34 | + <ReCAPTCHA sitekey="xxx" grecaptcha={grecaptchaMock} />, |
| 35 | + ); |
36 | 36 | assert.ok(instance); |
37 | 37 | }); |
38 | 38 | it("reset, should call grecaptcha.reset with the widget id", (done) => { |
39 | | - let grecaptchaMock = { |
40 | | - render() { |
| 39 | + const grecaptchaMock = { |
| 40 | + render () { |
41 | 41 | return "someWidgetId"; |
42 | 42 | }, |
43 | 43 |
|
44 | | - reset(widgetId) { |
| 44 | + reset (widgetId) { |
45 | 45 | assert.isNotNull(widgetId); |
46 | 46 | done(); |
47 | 47 | }, |
48 | 48 | }; |
49 | | - let instance = ReactTestUtils.renderIntoDocument( |
50 | | - <ReCAPTCHA sitekey="xxx" grecaptcha={grecaptchaMock} /> |
51 | | - ); |
| 49 | + const instance = ReactTestUtils.renderIntoDocument( |
| 50 | + <ReCAPTCHA sitekey="xxx" grecaptcha={grecaptchaMock} />, |
| 51 | + ); |
52 | 52 | instance.reset(); |
53 | 53 | }); |
| 54 | + it("execute, should call grecaptcha.execute with the widget id", (done) => { |
| 55 | + const grecaptchaMock = { |
| 56 | + render () { |
| 57 | + return "someWidgetId"; |
| 58 | + }, |
| 59 | + |
| 60 | + execute (widgetId) { |
| 61 | + assert.isNotNull(widgetId); |
| 62 | + done(); |
| 63 | + }, |
| 64 | + }; |
| 65 | + const instance = ReactTestUtils.renderIntoDocument( |
| 66 | + <ReCAPTCHA sitekey="xxx" size="invisible" grecaptcha={grecaptchaMock} />, |
| 67 | + ); |
| 68 | + instance.execute(); |
| 69 | + }); |
54 | 70 | describe("Expired", () => { |
55 | 71 | it("should call onChange with null when response is expired"); |
56 | 72 | it("should call onExpired when response is expired"); |
|
0 commit comments