1
- describe ( 'Quantcast' , function ( ) {
2
-
3
- var analytics = require ( 'analytics' ) ;
4
-
5
-
6
- describe ( 'initialize' , function ( ) {
7
-
8
- this . timeout ( 10000 ) ;
9
-
10
- it ( 'should call ready and load library' , function ( done ) {
11
- var spy = sinon . spy ( )
12
- , push = Array . prototype . push ;
13
1
14
- expect ( window . _qevents ) . to . be ( undefined ) ;
15
-
16
- analytics . ready ( spy ) ;
17
- analytics . initialize ( { 'Quantcast' : test [ 'Quantcast' ] } ) ;
2
+ describe ( 'Quantcast' , function ( ) {
18
3
19
- expect ( window . _qevents ) . not . to . be ( undefined ) ;
20
- expect ( window . _qevents . push ) . to . equal ( push ) ;
4
+ var analytics = window . analytics || require ( 'analytics' )
5
+ , assert = require ( 'assert' )
6
+ , sinon = require ( 'sinon' )
7
+ , when = require ( 'when' ) ;
8
+
9
+ var settings = {
10
+ pCode : 'x'
11
+ } ;
12
+
13
+ before ( function ( done ) {
14
+ this . timeout ( 10000 ) ;
15
+ this . spy = sinon . spy ( ) ;
16
+ analytics . ready ( this . spy ) ;
17
+ analytics . initialize ( { Quantcast : settings } ) ;
18
+ this . integration = analytics . _integrations . Quantcast ;
19
+ this . options = this . integration . options ;
20
+ when ( function ( ) { return window . __qc ; } , done ) ;
21
+ } ) ;
22
+
23
+ describe ( '#key' , function ( ) {
24
+ it ( 'pCode' , function ( ) {
25
+ assert ( this . integration . key == 'pCode' ) ;
26
+ } ) ;
27
+ } ) ;
21
28
22
- // When the library loads, it will overwrite the push method.
23
- var interval = setInterval ( function ( ) {
24
- if ( window . _qevents . push === push ) return ;
25
- expect ( window . _qevents . push ) . not . to . equal ( push ) ;
26
- expect ( window . __qc ) . not . to . be ( undefined ) ;
27
- expect ( spy . called ) . to . be ( true ) ;
28
- clearInterval ( interval ) ;
29
- done ( ) ;
30
- } , 20 ) ;
31
- } ) ;
29
+ describe ( '#defaults' , function ( ) {
30
+ it ( 'pCode' , function ( ) {
31
+ assert ( this . integration . defaults . pCode === null ) ;
32
+ } ) ;
33
+ } ) ;
32
34
33
- it ( 'should store options ', function ( ) {
34
- analytics . initialize ( { 'Quantcast' : test [ 'Quantcast' ] } ) ;
35
- expect ( analytics . _providers [ 0 ] . options . pCode ) . to . equal ( test [ 'Quantcast' ] ) ;
36
- } ) ;
35
+ describe ( '#initialize ', function ( ) {
36
+ it ( 'should call ready' , function ( ) {
37
+ assert ( this . spy . called ) ;
38
+ } ) ;
37
39
40
+ it ( 'should store options' , function ( ) {
41
+ assert ( this . options . pCode == settings . pCode ) ;
38
42
} ) ;
43
+ } ) ;
39
44
40
45
} ) ;
0 commit comments