File tree 3 files changed +47
-4
lines changed
3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -393,9 +393,9 @@ async function run() {
393
393
394
394
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
395
395
const tagName = core . getInput ( 'tag_name' , { required : true } ) ;
396
+
396
397
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
397
398
const tag = tagName . replace ( 'refs/tags/' , '' ) ;
398
- // This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
399
399
const releaseName = core . getInput ( 'release_name' , { required : true } ) . replace ( 'refs/tags/' , '' ) ;
400
400
const draft = core . getInput ( 'draft' , { required : false } ) === 'true' ;
401
401
const prerelease = core . getInput ( 'prerelease' , { required : false } ) === 'true' ;
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ async function run() {
11
11
12
12
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
13
13
const tagName = core . getInput ( 'tag_name' , { required : true } ) ;
14
+
14
15
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
15
16
const tag = tagName . replace ( 'refs/tags/' , '' ) ;
16
- // This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
17
17
const releaseName = core . getInput ( 'release_name' , { required : true } ) . replace ( 'refs/tags/' , '' ) ;
18
18
const draft = core . getInput ( 'draft' , { required : false } ) === 'true' ;
19
19
const prerelease = core . getInput ( 'prerelease' , { required : false } ) === 'true' ;
Original file line number Diff line number Diff line change
1
+ jest . mock ( '@actions/core' ) ;
2
+ jest . mock ( '@actions/github' ) ;
3
+
4
+ const core = require ( '@actions/core' ) ;
5
+ const { GitHub, context } = require ( '@actions/github' ) ;
6
+ const run = require ( '../src/main.js' ) ;
7
+
1
8
/* eslint-disable no-undef */
2
- describe ( 'Create release' , ( ) => {
3
- test ( 'Create release endpoint is called' , async ( ) => { } ) ;
9
+ describe ( 'module' , ( ) => {
10
+ let createRelease ;
11
+
12
+ beforeEach ( ( ) => {
13
+ core . getInput = jest . fn ( )
14
+ . mockReturnValueOnce ( 'refs/tags/v1.0.0' )
15
+ . mockReturnValueOnce ( 'myRelease' )
16
+ . mockReturnValueOnce ( 'false' )
17
+ . mockReturnValueOnce ( 'false' ) ;
18
+
19
+ createRelease = jest . fn ( ) ;
20
+
21
+ context . repo = {
22
+ owner : 'owner' ,
23
+ repo : 'repo'
24
+ } ;
25
+
26
+ const github = {
27
+ repos : {
28
+ createRelease
29
+ }
30
+ } ;
31
+
32
+ GitHub . mockImplementation ( ( ) => github ) ;
33
+ } ) ;
34
+
35
+ test ( 'Create release endpoint is called' , async ( ) => {
36
+ await run ( ) ;
37
+
38
+ expect ( createRelease ) . toHaveBeenCalledWith ( {
39
+ owner : 'owner' ,
40
+ repo : 'repo' ,
41
+ tag_name : 'v1.0.0' ,
42
+ name : 'myRelease' ,
43
+ draft : false ,
44
+ prerelease : false
45
+ } ) ;
46
+ } ) ;
4
47
5
48
test ( 'Outputs are set' , async ( ) => { } ) ;
6
49
} ) ;
You can’t perform that action at this time.
0 commit comments