@@ -4,7 +4,6 @@ import { getPublishCommand } from "../helpers/commands.js"
44import { cmd } from "../helpers/cmd.js"
55import { report } from "../helpers/reporter.js"
66import { runPublish } from "../modules/publish.js"
7- import { setRollback } from "../helpers/rollback.js"
87
98jest . mock ( "../helpers/cmd.js" , ( ) => ( {
109 cmd : jest . fn ( ) ,
@@ -42,25 +41,15 @@ const privateEntry = {
4241const baseConfig = {
4342 npmTag : "" ,
4443 preid : "" ,
44+ packages : [ entry , privateEntry ] ,
4545}
4646
4747describe ( "runPublish()" , ( ) => {
4848 it ( "publishes package" , async ( ) => {
4949 // When
50- await runPublish ( baseConfig , entry )
50+ await runPublish ( baseConfig )
5151 // Then
52- expect ( cmd ) . toBeCalledWith (
53- getPublishCommand ( entry . name , "latest" ) ,
54- baseConfig ,
55- true
56- )
57- } )
58-
59- it ( "does not publish private package" , async ( ) => {
60- // When
61- await runPublish ( baseConfig , privateEntry )
62- // Then
63- expect ( cmd ) . not . toBeCalled ( )
52+ expect ( cmd ) . toBeCalledWith ( getPublishCommand ( "latest" ) , baseConfig , true )
6453 } )
6554
6655 it ( "publishes with npm tag if given" , async ( ) => {
@@ -70,29 +59,18 @@ describe("runPublish()", () => {
7059 npmTag : "next" ,
7160 }
7261 // When
73- await runPublish ( config , entry )
62+ await runPublish ( config )
7463 // Then
75- expect ( cmd ) . toBeCalledWith (
76- getPublishCommand ( entry . name , "next" ) ,
77- config ,
78- true
79- )
64+ expect ( cmd ) . toBeCalledWith ( getPublishCommand ( "next" ) , config , true )
8065 } )
8166
8267 it ( "publishes with preid if given" , async ( ) => {
8368 // Given
84- const config = {
85- ...baseConfig ,
86- preid : "alpha" ,
87- }
69+ const config = { ...baseConfig , preid : "alpha" }
8870 // When
89- await runPublish ( config , entry )
71+ await runPublish ( config )
9072 // Then
91- expect ( cmd ) . toBeCalledWith (
92- getPublishCommand ( entry . name , "alpha" ) ,
93- config ,
94- true
95- )
73+ expect ( cmd ) . toBeCalledWith ( getPublishCommand ( "alpha" ) , config , true )
9674 } )
9775
9876 it ( "publishes with parsed preid if it exists" , async ( ) => {
@@ -102,67 +80,28 @@ describe("runPublish()", () => {
10280 releaseVersion : "0.0.1-beta.0" ,
10381 }
10482 // When
105- await runPublish ( config , entry )
106- // Then
107- expect ( cmd ) . toBeCalledWith (
108- getPublishCommand ( entry . name , "beta" ) ,
109- config ,
110- true
111- )
112- } )
113-
114- it ( "adds publish action if public" , async ( ) => {
115- // When
116- await runPublish ( baseConfig , entry )
83+ await runPublish ( config )
11784 // Then
118- // eslint-disable-next-line no-unused-vars
119- expect ( setRollback ) . toBeCalledWith (
120- expect . objectContaining ( baseConfig ) ,
121- expect . objectContaining ( {
122- type : "publish" ,
123- callback : expect . any ( Function ) ,
124- } )
125- )
85+ expect ( cmd ) . toBeCalledWith ( getPublishCommand ( "beta" ) , config , true )
12686 } )
12787
12888 describe ( "report" , ( ) => {
12989 it ( "reports start" , async ( ) => {
13090 // When
131- await runPublish ( baseConfig , entry )
91+ await runPublish ( baseConfig )
13292 // Then
13393 expect ( report ) . toBeCalledWith (
134- expect . objectContaining ( {
135- m : `Publishing ${ entry . name } ...` ,
136- type : "start" ,
137- } )
138- )
139- } )
140-
141- it ( "reports private publish skipped" , async ( ) => {
142- // When
143- await runPublish ( baseConfig , privateEntry )
144- // Then
145- expect ( report ) . toBeCalledWith (
146- expect . objectContaining ( {
147- m : {
148- text : `Publish skipped (private): ${ privateEntry . name } ` ,
149- symbol : "☕" ,
150- } ,
151- type : "stopAndPersist" ,
152- } )
94+ expect . objectContaining ( { m : `Publishing...` , type : "start" } )
15395 )
15496 } )
15597
15698 it ( "reports publish success" , async ( ) => {
15799 // When
158- await runPublish ( baseConfig , entry )
100+ await runPublish ( baseConfig )
159101 // Then
160102 expect ( report ) . toBeCalledWith (
161103 expect . objectContaining ( {
162- m : {
163- text : `Published ${ entry . name } ` ,
164- symbol : "🚀" ,
165- } ,
104+ m : { text : `Published` , symbol : "🚀" } ,
166105 type : "stopAndPersist" ,
167106 } )
168107 )
0 commit comments