@@ -4,6 +4,9 @@ import chai, { expect } from 'chai';
4
4
import Config from './config' ;
5
5
import path from 'path' ;
6
6
import sinon from 'ts-sinon' ;
7
+ import type writeAnalyticsConfigType from './analytics' ;
8
+ import type { publishNpmPackages as publishNpmPackagesType } from './npm-packages' ;
9
+ import type uploadDownloadCenterConfigType from './download-center' ;
7
10
8
11
chai . use ( require ( 'sinon-chai' ) ) ;
9
12
@@ -13,8 +16,9 @@ function createStubRepo(overrides?: any): GithubRepo {
13
16
14
17
describe ( 'publish' , ( ) => {
15
18
let config : Config ;
16
- let uploadDownloadCenterConfig : ( version : string , awsKey : string , awsSecret : string ) => Promise < any > ;
17
- let publishNpmPackages : ( config : Config ) => Promise < void > ;
19
+ let uploadDownloadCenterConfig : typeof uploadDownloadCenterConfigType ;
20
+ let publishNpmPackages : typeof publishNpmPackagesType ;
21
+ let writeAnalyticsConfig : typeof writeAnalyticsConfigType ;
18
22
let githubRepo : GithubRepo ;
19
23
20
24
beforeEach ( ( ) => {
@@ -50,6 +54,7 @@ describe('publish', () => {
50
54
51
55
uploadDownloadCenterConfig = sinon . spy ( ) ;
52
56
publishNpmPackages = sinon . spy ( ) ;
57
+ writeAnalyticsConfig = sinon . spy ( ) ;
53
58
githubRepo = createStubRepo ( ) ;
54
59
} ) ;
55
60
@@ -65,7 +70,8 @@ describe('publish', () => {
65
70
config ,
66
71
githubRepo ,
67
72
uploadDownloadCenterConfig ,
68
- publishNpmPackages
73
+ publishNpmPackages ,
74
+ writeAnalyticsConfig
69
75
) ;
70
76
71
77
expect ( uploadDownloadCenterConfig ) . to . have . been . calledWith (
@@ -80,21 +86,25 @@ describe('publish', () => {
80
86
config ,
81
87
githubRepo ,
82
88
uploadDownloadCenterConfig ,
83
- publishNpmPackages
89
+ publishNpmPackages ,
90
+ writeAnalyticsConfig
84
91
) ;
85
92
86
93
expect ( githubRepo . promoteRelease ) . to . have . been . calledWith ( config ) ;
87
94
} ) ;
88
95
89
- it ( 'publishes NPM packages' , async ( ) => {
96
+ it ( 'writes analytics config and then publishes NPM packages' , async ( ) => {
90
97
await publish (
91
98
config ,
92
99
githubRepo ,
93
100
uploadDownloadCenterConfig ,
94
- publishNpmPackages
101
+ publishNpmPackages ,
102
+ writeAnalyticsConfig
95
103
) ;
96
104
105
+ expect ( writeAnalyticsConfig ) . to . have . been . calledOnce ;
97
106
expect ( publishNpmPackages ) . to . have . been . calledWith ( ) ;
107
+ expect ( publishNpmPackages ) . to . have . been . calledAfter ( writeAnalyticsConfig as any ) ;
98
108
} ) ;
99
109
} ) ;
100
110
@@ -110,7 +120,8 @@ describe('publish', () => {
110
120
config ,
111
121
githubRepo ,
112
122
uploadDownloadCenterConfig ,
113
- publishNpmPackages
123
+ publishNpmPackages ,
124
+ writeAnalyticsConfig
114
125
) ;
115
126
116
127
expect ( uploadDownloadCenterConfig ) . not . to . have . been . called ;
@@ -121,7 +132,8 @@ describe('publish', () => {
121
132
config ,
122
133
githubRepo ,
123
134
uploadDownloadCenterConfig ,
124
- publishNpmPackages
135
+ publishNpmPackages ,
136
+ writeAnalyticsConfig
125
137
) ;
126
138
127
139
expect ( githubRepo . promoteRelease ) . not . to . have . been . called ;
@@ -132,7 +144,8 @@ describe('publish', () => {
132
144
config ,
133
145
githubRepo ,
134
146
uploadDownloadCenterConfig ,
135
- publishNpmPackages
147
+ publishNpmPackages ,
148
+ writeAnalyticsConfig
136
149
) ;
137
150
138
151
expect ( publishNpmPackages ) . not . to . have . been . called ;
0 commit comments