Skip to content

Commit 259c66a

Browse files
committed
MockCfEnv can work more like regular CfEnv
1 parent aca79b4 commit 259c66a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/__mocks__/cf-env.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
"use strict";
22

3-
const cfEnv = {
3+
class CfEnv {
44
_reset() {
55
this.isOnCf = false;
66
this.cfApp = {};
77
this.cfServices = {};
88
this.cfServiceCredentialsForLabel = jest.fn().mockReturnValue({});
9-
},
10-
};
11-
cfEnv._reset();
12-
13-
const CfEnv = {
14-
getInstance: () => cfEnv,
15-
};
9+
}
10+
constructor() {
11+
this._reset();
12+
}
13+
static getInstance() {
14+
if (!CfEnv.__instance) {
15+
CfEnv.__instance = new CfEnv();
16+
}
17+
return CfEnv.__instance;
18+
}
19+
}
1620

1721
module.exports = { CfEnv };

0 commit comments

Comments
 (0)