@@ -9,6 +9,8 @@ import pictures1ImageableMock from 'fixtures/api/pictures/1/imageable';
99import pictures5Mock from 'fixtures/api/pictures/5' ;
1010import pictures5ImageableMock from 'fixtures/api/pictures/5/imageable' ;
1111
12+ import config from '../../config/environment' ;
13+
1214module ( 'Acceptance | polymorphic' , {
1315 beforeEach : function ( ) {
1416 this . sandbox = window . sinon . sandbox . create ( ) ;
@@ -23,7 +25,7 @@ module('Acceptance | polymorphic', {
2325
2426test ( 'visiting /pictures list' , function ( assert ) {
2527 assert . expect ( 6 ) ;
26- setupFetchResonses ( this . sandbox ) ;
28+ setupFetchResponses ( this . sandbox ) ;
2729
2830 visit ( '/pictures' ) ;
2931 andThen ( function ( ) {
@@ -39,7 +41,7 @@ test('visiting /pictures list', function(assert) {
3941
4042test ( 'visiting /pictures/1, picture with an (imageable) product relation' , function ( assert ) {
4143 assert . expect ( 3 ) ;
42- setupFetchResonses ( this . sandbox ) ;
44+ setupFetchResponses ( this . sandbox ) ;
4345
4446 visit ( '/pictures/1' ) ;
4547 andThen ( function ( ) {
@@ -54,7 +56,7 @@ test('visiting /pictures/1, picture with an (imageable) product relation', funct
5456
5557test ( 'visiting /pictures/5, picture with an (imageable) employee relation' , function ( assert ) {
5658 assert . expect ( 3 ) ;
57- setupFetchResonses ( this . sandbox ) ;
59+ setupFetchResponses ( this . sandbox ) ;
5860
5961 visit ( '/pictures/5' ) ;
6062 andThen ( function ( ) {
@@ -68,27 +70,28 @@ test('visiting /pictures/5, picture with an (imageable) employee relation', func
6870} ) ;
6971
7072
71- function setupFetchResonses ( sandbox ) {
73+ function setupFetchResponses ( sandbox ) {
74+ const apiUrl = [ config . APP . API_HOST , config . APP . API_PATH ] . join ( '/' ) ;
7275 sandbox . stub ( window , 'fetch' , function ( url ) {
7376 let resp ;
7477 switch ( url ) {
75- case 'api/v1/ pictures?sort=id&include=imageable' :
78+ case [ apiUrl , ' pictures?sort=id&include=imageable'] . join ( '/' ) :
7679 resp = picturesMockResponse ( ) ;
7780 break ;
78- case 'api/v1/ pictures/1' :
81+ case [ apiUrl , ' pictures/1'] . join ( '/' ) :
7982 resp = pictures1MockResponse ( ) ;
8083 break ;
81- case '/api/v1/ pictures/1/imageable' :
84+ case [ apiUrl , ' pictures/1/imageable'] . join ( '/' ) :
8285 resp = pictures1ImageableMockResponse ( ) ;
8386 break ;
84- case 'api/v1/ pictures/5' :
87+ case [ apiUrl , ' pictures/5'] . join ( '/' ) :
8588 resp = pictures5MockResponse ( ) ;
8689 break ;
87- case '/api/v1/ pictures/5/imageable' :
90+ case [ apiUrl , ' pictures/5/imageable'] . join ( '/' ) :
8891 resp = pictures5ImageableMockResponse ( ) ;
8992 break ;
9093 default :
91- throw ( 'no mocked fetch reponse for request' ) ;
94+ throw ( 'no mocked fetch reponse for request: ' + url ) ;
9295 }
9396 return resp ;
9497 } ) ;
0 commit comments