@@ -4,10 +4,10 @@ import { LoggerStub } from "../stubs";
4
4
import { CompanyInsightsController } from "../../lib/controllers/company-insights-controller" ;
5
5
6
6
describe ( "companyInsightsController" , ( ) => {
7
- const insightsUrlEndpoint = "/api/insights" ;
7
+ const insightsUrlEndpoint = "/api/insights?ipAddress=%s " ;
8
8
const currentIp = "8.8.8.8" ;
9
9
const profileDir = "profileDir" ;
10
- const cacheTimeout = 48 * 60 * 60 * 1000 ; // 2 days in milliseconds
10
+ const cacheTimeout = 30 * 24 * 60 * 60 * 1000 ; // 2 days in milliseconds
11
11
const defaultCompanyData = {
12
12
company : {
13
13
name : "Progress" ,
@@ -138,6 +138,17 @@ describe("companyInsightsController", () => {
138
138
const companyData = await companyInsightsController . getCompanyData ( ) ;
139
139
assert . deepEqual ( companyData , null ) ;
140
140
} ) ;
141
+
142
+ it ( "unable to get current ip address" , async ( ) => {
143
+ const ipService = testInjector . resolve < IIPService > ( "ipService" ) ;
144
+ ipService . getCurrentIPv4Address = async ( ) : Promise < string > => { throw new Error ( "Unable to get current ip addreess" ) ; } ;
145
+
146
+ const companyData = await companyInsightsController . getCompanyData ( ) ;
147
+ assert . deepEqual ( companyData , null ) ;
148
+ assert . equal ( httpRequestCounter , 0 , "We should not have any http request" ) ;
149
+ assert . deepEqual ( dataPassedToGetSettingValue , [ ] , "When we are unable to get IP, we should not try to get value from the cache." ) ;
150
+ assert . deepEqual ( dataPassedToSaveSettingValue , [ ] , "When we are unable to get IP, we should not persist anything." ) ;
151
+ } ) ;
141
152
} ) ;
142
153
143
154
describe ( "returns correct data when" , ( ) => {
@@ -155,17 +166,6 @@ describe("companyInsightsController", () => {
155
166
156
167
describe ( "data for current ip does not exist in the cache and" , ( ) => {
157
168
158
- it ( "unable to get current ip address, but still can get company information" , async ( ) => {
159
- const ipService = testInjector . resolve < IIPService > ( "ipService" ) ;
160
- ipService . getCurrentIPv4Address = async ( ) : Promise < string > => { throw new Error ( "Unable to get current ip addreess" ) ; } ;
161
-
162
- const companyData = await companyInsightsController . getCompanyData ( ) ;
163
- assert . deepEqual ( companyData , defaultExpectedCompanyData ) ;
164
- assert . equal ( httpRequestCounter , 1 , "We should have only one http request" ) ;
165
- assert . deepEqual ( dataPassedToGetSettingValue , [ ] , "When we are unable to get IP, we should not try to get value from the cache." ) ;
166
- assert . deepEqual ( dataPassedToSaveSettingValue , [ ] , "When we are unable to get IP, we should not persist anything." ) ;
167
- } ) ;
168
-
169
169
it ( "response contains company property" , async ( ) => {
170
170
const companyData = await companyInsightsController . getCompanyData ( ) ;
171
171
assert . deepEqual ( companyData , defaultExpectedCompanyData ) ;
0 commit comments