44
44
45
45
const date = new Date ( '2023-04-20T23:52:39.543Z' ) ;
46
46
47
- const publishNpm = require ( '../publish-npm' ) ;
47
+ const { publishNpm} = require ( '../publish-npm' ) ;
48
48
let consoleError ;
49
49
50
50
describe ( 'publish-npm' , ( ) => {
@@ -68,15 +68,15 @@ describe('publish-npm', () => {
68
68
69
69
describe ( 'publish-npm.js' , ( ) => {
70
70
it ( 'Fails when invalid build type is passed' , ( ) => {
71
- expect ( ( ) => publishNpm ( 'invalid' ) ) . toThrowError (
71
+ expect ( publishNpm ( 'invalid' ) ) . rejects . toThrow (
72
72
'Unsupported build type: invalid' ,
73
73
) ;
74
74
} ) ;
75
75
} ) ;
76
76
77
77
describe ( 'dry-run' , ( ) => {
78
- it ( 'should set version and not publish' , ( ) => {
79
- publishNpm ( 'dry-run' ) ;
78
+ it ( 'should set version and not publish' , async ( ) => {
79
+ await publishNpm ( 'dry-run' ) ;
80
80
81
81
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
82
82
expect ( exitMock ) . toHaveBeenCalledWith ( 0 ) ;
@@ -93,13 +93,13 @@ describe('publish-npm', () => {
93
93
} ) ;
94
94
95
95
describe ( 'nightly' , ( ) => {
96
- it ( 'should publish' , ( ) => {
96
+ it ( 'should publish' , async ( ) => {
97
97
execMock
98
98
. mockReturnValueOnce ( { stdout : '0.81.0-rc.1\n' , code : 0 } )
99
99
. mockReturnValueOnce ( { code : 0 } ) ;
100
100
const expectedVersion = '0.82.0-nightly-20230420-currentco' ;
101
101
102
- publishNpm ( 'nightly' ) ;
102
+ await publishNpm ( 'nightly' ) ;
103
103
104
104
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
105
105
expect ( publishAndroidArtifactsToMavenMock ) . toHaveBeenCalledWith (
@@ -116,14 +116,14 @@ describe('publish-npm', () => {
116
116
expect ( exitMock ) . toHaveBeenCalledWith ( 0 ) ;
117
117
} ) ;
118
118
119
- it ( 'should fail to set version' , ( ) => {
119
+ it ( 'should fail to set version' , async ( ) => {
120
120
execMock . mockReturnValueOnce ( { stdout : '0.81.0-rc.1\n' , code : 0 } ) ;
121
121
const expectedVersion = '0.82.0-nightly-20230420-currentco' ;
122
122
setReactNativeVersionMock . mockImplementation ( ( ) => {
123
123
throw new Error ( 'something went wrong' ) ;
124
124
} ) ;
125
125
126
- publishNpm ( 'nightly' ) ;
126
+ await publishNpm ( 'nightly' ) ;
127
127
128
128
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
129
129
expect ( publishAndroidArtifactsToMavenMock ) . not . toBeCalled ( ) ;
@@ -140,19 +140,19 @@ describe('publish-npm', () => {
140
140
describe ( 'release' , ( ) => {
141
141
it ( 'should fail with invalid release version' , ( ) => {
142
142
process . env . CIRCLE_TAG = '1.0.1' ;
143
- expect ( ( ) => {
144
- publishNpm ( 'release' ) ;
145
- } ) . toThrow ( 'Version 1.0.1 is not valid for Release' ) ;
143
+ expect ( publishNpm ( 'release' ) ) . rejects . toThrow (
144
+ 'Version 1.0.1 is not valid for Release' ,
145
+ ) ;
146
146
expect ( publishAndroidArtifactsToMavenMock ) . not . toBeCalled ( ) ;
147
147
} ) ;
148
148
149
- it ( 'should publish non-latest' , ( ) => {
149
+ it ( 'should publish non-latest' , async ( ) => {
150
150
execMock . mockReturnValueOnce ( { code : 0 } ) ;
151
151
isTaggedLatestMock . mockReturnValueOnce ( false ) ;
152
152
process . env . CIRCLE_TAG = '0.81.1' ;
153
153
process . env . NPM_CONFIG_OTP = 'otp' ;
154
154
155
- publishNpm ( 'release' ) ;
155
+ await publishNpm ( 'release' ) ;
156
156
157
157
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
158
158
const expectedVersion = '0.81.1' ;
@@ -171,13 +171,13 @@ describe('publish-npm', () => {
171
171
expect ( execMock . mock . calls ) . toHaveLength ( 1 ) ;
172
172
} ) ;
173
173
174
- it ( 'should publish latest stable' , ( ) => {
174
+ it ( 'should publish latest stable' , async ( ) => {
175
175
execMock . mockReturnValueOnce ( { code : 0 } ) ;
176
176
isTaggedLatestMock . mockReturnValueOnce ( true ) ;
177
177
process . env . CIRCLE_TAG = '0.81.1' ;
178
178
process . env . NPM_CONFIG_OTP = 'otp' ;
179
179
180
- publishNpm ( 'release' ) ;
180
+ await publishNpm ( 'release' ) ;
181
181
182
182
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
183
183
const expectedVersion = '0.81.1' ;
@@ -196,13 +196,13 @@ describe('publish-npm', () => {
196
196
expect ( execMock . mock . calls ) . toHaveLength ( 1 ) ;
197
197
} ) ;
198
198
199
- it ( 'should fail to publish latest stable' , ( ) => {
199
+ it ( 'should fail to publish latest stable' , async ( ) => {
200
200
execMock . mockReturnValueOnce ( { code : 1 } ) ;
201
201
isTaggedLatestMock . mockReturnValueOnce ( true ) ;
202
202
process . env . CIRCLE_TAG = '0.81.1' ;
203
203
process . env . NPM_CONFIG_OTP = 'otp' ;
204
204
205
- publishNpm ( 'release' ) ;
205
+ await publishNpm ( 'release' ) ;
206
206
207
207
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
208
208
const expectedVersion = '0.81.1' ;
@@ -219,13 +219,13 @@ describe('publish-npm', () => {
219
219
expect ( execMock . mock . calls ) . toHaveLength ( 1 ) ;
220
220
} ) ;
221
221
222
- it ( 'should publish next' , ( ) => {
222
+ it ( 'should publish next' , async ( ) => {
223
223
execMock . mockReturnValueOnce ( { code : 0 } ) ;
224
224
isTaggedLatestMock . mockReturnValueOnce ( true ) ;
225
225
process . env . CIRCLE_TAG = '0.81.0-rc.4' ;
226
226
process . env . NPM_CONFIG_OTP = 'otp' ;
227
227
228
- publishNpm ( 'release' ) ;
228
+ await publishNpm ( 'release' ) ;
229
229
230
230
expect ( removeNewArchFlags ) . not . toHaveBeenCalled ( ) ;
231
231
const expectedVersion = '0.81.0-rc.4' ;
0 commit comments