@@ -80,6 +80,96 @@ describe('utils', () => {
80
80
expect ( validTags ) . toHaveLength ( 1 ) ;
81
81
} ) ;
82
82
83
+ it ( 'returns valid tags #2' , async ( ) => {
84
+ /*
85
+ * Given
86
+ */
87
+ const testTags = [
88
+ {
89
+ name : 'v1.0.0' ,
90
+ commit : { sha : 'string' , url : 'string' } ,
91
+ zipball_url : 'string' ,
92
+ tarball_url : 'string' ,
93
+ node_id : 'string' ,
94
+ } ,
95
+ {
96
+ name : '0.0.91' ,
97
+ commit : { sha : 'string' , url : 'string' } ,
98
+ zipball_url : 'string' ,
99
+ tarball_url : 'string' ,
100
+ node_id : 'string' ,
101
+ } ,
102
+ ] ;
103
+ const mockListTags = jest
104
+ . spyOn ( github , 'listTags' )
105
+ . mockImplementation ( async ( ) => testTags ) ;
106
+
107
+ const regex_2 = / ^ / ;
108
+
109
+ /*
110
+ * When
111
+ */
112
+ const validTags = await getValidTags ( regex_2 , false , true ) ;
113
+
114
+ /*
115
+ * Then
116
+ */
117
+ expect ( mockListTags ) . toHaveBeenCalled ( ) ;
118
+ expect ( validTags ) . toHaveLength ( 1 ) ;
119
+ expect ( validTags [ 0 ] ) . toEqual ( {
120
+ name : '0.0.91' ,
121
+ commit : { sha : 'string' , url : 'string' } ,
122
+ zipball_url : 'string' ,
123
+ tarball_url : 'string' ,
124
+ node_id : 'string' ,
125
+ } ) ;
126
+ } ) ;
127
+
128
+ it ( 'returns valid tags #3' , async ( ) => {
129
+ /*
130
+ * Given
131
+ */
132
+ const testTags = [
133
+ {
134
+ name : 'v1.0.0' ,
135
+ commit : { sha : 'string' , url : 'string' } ,
136
+ zipball_url : 'string' ,
137
+ tarball_url : 'string' ,
138
+ node_id : 'string' ,
139
+ } ,
140
+ {
141
+ name : '1.0.91' ,
142
+ commit : { sha : 'string' , url : 'string' } ,
143
+ zipball_url : 'string' ,
144
+ tarball_url : 'string' ,
145
+ node_id : 'string' ,
146
+ } ,
147
+ ] ;
148
+ const mockListTags = jest
149
+ . spyOn ( github , 'listTags' )
150
+ . mockImplementation ( async ( ) => testTags ) ;
151
+
152
+ const regex_2 = / ^ v / ;
153
+
154
+ /*
155
+ * When
156
+ */
157
+ const validTags = await getValidTags ( regex_2 , false , true ) ;
158
+
159
+ /*
160
+ * Then
161
+ */
162
+ expect ( mockListTags ) . toHaveBeenCalled ( ) ;
163
+ expect ( validTags ) . toHaveLength ( 1 ) ;
164
+ expect ( validTags [ 0 ] ) . toEqual ( {
165
+ name : 'v1.0.0' ,
166
+ commit : { sha : 'string' , url : 'string' } ,
167
+ zipball_url : 'string' ,
168
+ tarball_url : 'string' ,
169
+ node_id : 'string' ,
170
+ } ) ;
171
+ } ) ;
172
+
83
173
it ( 'returns sorted tags' , async ( ) => {
84
174
/*
85
175
* Given
0 commit comments