@@ -2,100 +2,83 @@ var request = require("supertest"),
22validators = require ( "../validators" ) ,
33settings = require ( "../settings" ) ;
44
5- it ( "should return metadata" , function ( done ) {
6- request ( settings . host )
7- . get ( "/columns" )
8- . expect ( validators . aSuccessfulRequest )
9- . expect ( validators . json )
10- . expect ( validators . metadata )
11- . end ( function ( error : any , res : any ) {
12- if ( error ) return done ( error ) ;
13- done ( ) ;
14- } ) ;
5+ it ( "should return metadata" , async function ( ) {
6+ const localResponse = await request ( settings . host )
7+ . get ( "/columns" )
8+ . expect ( validators . aSuccessfulRequest )
9+ . expect ( validators . json )
10+ . expect ( validators . metadata )
11+ await validators . compareWithProduction ( "/columns" , localResponse ) ;
1512} ) ;
1613
14+
15+
16+
1717//Fixed this test to work on dev and local
18- it ( "should return a sample" , function ( done ) {
19- request ( settings . host )
20- . get ( "/columns?sample" )
21- . expect ( validators . aSuccessfulRequest )
22- . expect ( validators . json )
23- . expect ( validators . aSample )
24- . end ( function ( error : any , res : any ) {
25- if ( error ) return done ( error ) ;
26- done ( ) ;
27- } ) ;
18+ it ( "should return a sample" , async function ( ) {
19+ const localResponse = await request ( settings . host )
20+ . get ( "/columns?sample" )
21+ . expect ( validators . aSuccessfulRequest )
22+ . expect ( validators . json )
23+ . expect ( validators . aSample )
24+ await validators . compareWithProduction ( "/columns?sample" , localResponse ) ;
25+
2826} ) ;
2927
3028//Fixed this test to work on dev and local
31- it ( "should accept an interval name" , function ( done ) {
32- request ( settings . host )
29+ it ( "should accept an interval name" , async function ( ) {
30+ const localResponse = await request ( settings . host )
3331 . get ( "/columns?interval_name=Permian" )
3432 . expect ( validators . aSuccessfulRequest )
3533 . expect ( validators . json )
3634 . expect ( validators . atLeastOneResult )
37- . end ( function ( error : any , res : any ) {
38- if ( error ) return done ( error ) ;
39- done ( ) ;
40- } ) ;
35+ await validators . compareWithProduction ( "/columns?interval_name=Permian" , localResponse )
4136} ) ;
4237
4338
44- it ( "should accept an age" , function ( done ) {
45- request ( settings . host )
39+ it ( "should accept an age" , async function ( ) {
40+ const localResponse = await request ( settings . host )
4641 . get ( "/columns?age=271" )
4742 . expect ( validators . aSuccessfulRequest )
4843 . expect ( validators . json )
4944 . expect ( validators . atLeastOneResult )
50- . end ( function ( error : any , res : any ) {
51- if ( error ) return done ( error ) ;
52- done ( ) ;
53- } ) ;
45+ await validators . compareWithProduction ( "/columns?age=271" , localResponse )
5446} ) ;
5547
5648
57- it ( "should accept an age_top and age_bottom" , function ( done ) {
58- request ( settings . host )
49+ it ( "should accept an age_top and age_bottom" , async function ( ) {
50+ const localResponse = await request ( settings . host )
5951 . get ( "/columns?age_top=200&age_bottom=250" )
6052 . expect ( validators . aSuccessfulRequest )
6153 . expect ( validators . json )
6254 . expect ( validators . atLeastOneResult )
63- . end ( function ( error : any , res : any ) {
64- if ( error ) return done ( error ) ;
65- done ( ) ;
66- } ) ;
55+ await validators . compareWithProduction ( "/columns?age_top=200&age_bottom=250" , localResponse )
6756} ) ;
6857
6958//fixed test in dev and it is now working.
70- it ( "should accept a strat_name parameter" , function ( done ) {
71- request ( settings . host )
59+ it ( "should accept a strat_name parameter" , async function ( ) {
60+ const localResponse = await request ( settings . host )
7261 . get ( "/columns?strat_name=mancos" )
7362 . expect ( validators . aSuccessfulRequest )
7463 . expect ( validators . json )
7564 . expect ( validators . atLeastOneResult )
76- . end ( function ( error : any , res : any ) {
77- if ( error ) return done ( error ) ;
78- done ( ) ;
79- } ) ;
65+ await validators . compareWithProduction ( "/columns?strat_name=mancos" , localResponse )
8066} ) ;
8167
82- it ( "should accept a strat_name_id parameter" , function ( done ) {
83- request ( settings . host )
68+ it ( "should accept a strat_name_id parameter" , async function ( ) {
69+ const localResponse = await request ( settings . host )
8470 . get ( "/columns?strat_name_id=1205" )
8571 . expect ( validators . aSuccessfulRequest )
8672 . expect ( validators . json )
8773 . expect ( validators . atLeastOneResult )
88- . end ( function ( error : any , res : any ) {
89- if ( error ) return done ( error ) ;
90- done ( ) ;
91- } ) ;
74+ await validators . compareWithProduction ( "/columns?strat_name_id=1205" , localResponse )
9275} ) ;
9376
9477
9578//Checking to see if the rest of the tests below work in prod.
9679//count for max number of columns ~50?
97- it ( "should accept a latitude and longitude" , function ( done ) {
98- request ( settings . host )
80+ it ( "should accept a latitude and longitude" , async function ( ) {
81+ const localResponse = await request ( settings . host )
9982 . get ( "/columns?lat=43.3&lng=-89.3" )
10083 . expect ( validators . aSuccessfulRequest )
10184 . expect ( validators . json )
@@ -105,62 +88,45 @@ request(settings.host)
10588 throw new Error ( "Columns returning the wrong column for the lat/lng" ) ;
10689 }
10790 } )
108- . end ( function ( error : any , res : any ) {
109- if ( error ) return done ( error ) ;
110- done ( ) ;
111- } ) ;
91+ await validators . compareWithProduction ( "/columns?lat=43.3&lng=-89.3" , localResponse )
11292} ) ;
11393
114- it ( "should return topojson" , function ( done ) {
115- request ( settings . host )
94+ it ( "should return topojson" , async function ( ) {
95+ const localResponse = await request ( settings . host )
11696 . get ( "/columns?age=2&format=topojson" )
11797 . expect ( validators . aSuccessfulRequest )
11898 . expect ( validators . topoJSON )
119- . end ( function ( error : any , res : any ) {
120- if ( error ) return done ( error ) ;
121- done ( ) ;
122- } ) ;
12399} ) ;
124100
125- it ( "should return csv" , function ( done ) {
126- request ( settings . host )
101+ it ( "should return csv" , async function ( ) {
102+ const localResponse = await request ( settings . host )
127103 . get ( "/columns?age=2&format=csv" )
128104 . expect ( validators . aSuccessfulRequest )
129105 . expect ( validators . csv )
130- . end ( function ( error : any , res : any ) {
131- if ( error ) return done ( error ) ;
132- done ( ) ;
133- } ) ;
134106} ) ;
135107
136108
137- it ( "should accept a project_id" , function ( done ) {
109+ it ( "should accept a project_id" , async function ( ) {
138110 this . timeout ( 7000 ) ;
139- request ( settings . host )
111+ const localResponse = await request ( settings . host )
140112 . get ( "/columns?project_id=4" )
141113 . expect ( validators . aSuccessfulRequest )
142114 . expect ( validators . json )
143115 . expect ( validators . atLeastOneResult )
144- . end ( function ( error : any , res : any ) {
145- if ( error ) return done ( error ) ;
146- done ( ) ;
147- } ) ;
116+ await validators . compareWithProduction ( "/columns?project_id=4" , localResponse )
148117} ) ;
149118
150- it ( "should accept a lat/lng and return all adjacent columns" , function ( done ) {
151- request ( settings . host )
152- . get ( "/columns?lat=43.3&lng=-89.3&adjacents=true" )
153- . expect ( validators . aSuccessfulRequest )
154- . expect ( validators . json )
155- . expect ( validators . atLeastOneResult )
156- . expect ( function ( res : { body : { success : { data : string | any [ ] ; } ; } ; } ) {
157- if ( res . body . success . data . length != 6 ) {
158- throw new Error ( "Wrong number of adjacent columns being returned" ) ;
159- }
160- } )
161- . end ( function ( error : any , res : any ) {
162- if ( error ) return done ( error ) ;
163- done ( ) ;
164- } ) ;
119+ it ( "should accept a lat/lng and return all adjacent columns" , async function ( ) {
120+ const localResponse = await request ( settings . host )
121+ . get ( "/columns?lat=43.3&lng=-89.3&adjacents=true" )
122+ . expect ( validators . aSuccessfulRequest )
123+ . expect ( validators . json )
124+ . expect ( validators . atLeastOneResult )
125+ . expect ( function ( res : { body : { success : { data : string | any [ ] ; } ; } ; } ) {
126+ if ( res . body . success . data . length != 6 ) {
127+ throw new Error ( "Wrong number of adjacent columns being returned" ) ;
128+ }
129+ } )
130+ await validators . compareWithProduction ( "/columns?lat=43.3&lng=-89.3&adjacents=true" , localResponse )
165131} ) ;
166132
0 commit comments