|
| 1 | +component extends="tests.resources.ModuleIntegrationSpec" appMapping="/app" { |
| 2 | + |
| 3 | + function run() { |
| 4 | + describe( "GET requests", function() { |
| 5 | + beforeEach( function() { |
| 6 | + variables.hyper = getInstance( "Builder@Hyper" ); |
| 7 | + } ); |
| 8 | + |
| 9 | + afterEach( function() { |
| 10 | + if ( variables.keyExists( "hyper" ) ) { |
| 11 | + variables.delete( "hyper" ); |
| 12 | + } |
| 13 | + } ); |
| 14 | + |
| 15 | + it( "can make a GET request", function() { |
| 16 | + var res = hyper.get( "https://swapi.co/api/people/1" ); |
| 17 | + expect( res ).toBeInstanceOf( |
| 18 | + "HyperResponse", |
| 19 | + "A HyperResponse object should have been returned." |
| 20 | + ); |
| 21 | + var data = res.json(); |
| 22 | + expect( data ).toBeStruct( |
| 23 | + "Expected to deserialize JSON data from the response." |
| 24 | + ); |
| 25 | + expect( data ).toBe( { |
| 26 | + "name": "Luke Skywalker", |
| 27 | + "height": "172", |
| 28 | + "mass": "77", |
| 29 | + "hair_color": "blond", |
| 30 | + "skin_color": "fair", |
| 31 | + "eye_color": "blue", |
| 32 | + "birth_year": "19BBY", |
| 33 | + "gender": "male", |
| 34 | + "homeworld": "https://swapi.co/api/planets/1/", |
| 35 | + "films": [ |
| 36 | + "https://swapi.co/api/films/2/", |
| 37 | + "https://swapi.co/api/films/6/", |
| 38 | + "https://swapi.co/api/films/3/", |
| 39 | + "https://swapi.co/api/films/1/", |
| 40 | + "https://swapi.co/api/films/7/" |
| 41 | + ], |
| 42 | + "species": [ |
| 43 | + "https://swapi.co/api/species/1/" |
| 44 | + ], |
| 45 | + "vehicles": [ |
| 46 | + "https://swapi.co/api/vehicles/14/", |
| 47 | + "https://swapi.co/api/vehicles/30/" |
| 48 | + ], |
| 49 | + "starships": [ |
| 50 | + "https://swapi.co/api/starships/12/", |
| 51 | + "https://swapi.co/api/starships/22/" |
| 52 | + ], |
| 53 | + "created": "2014-12-09T13:50:51.644000Z", |
| 54 | + "edited": "2014-12-20T21:17:56.891000Z", |
| 55 | + "url": "https://swapi.co/api/people/1/" |
| 56 | + } ); |
| 57 | + } ); |
| 58 | + } ); |
| 59 | + } |
| 60 | + |
| 61 | +} |
0 commit comments