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