@@ -48,12 +48,21 @@ const moveData = {
4848} ;
4949
5050test ( 'generateMutationQuery move the card when in the correct project and wrong column' , t => {
51- t . deepEqual ( generateMutationQuery ( moveData , project , column , nodeId ) , [
51+ t . deepEqual ( generateMutationQuery ( moveData , project , column , nodeId , 'update' ) , [
5252 `mutation {
53- moveProjectCard( input: {
54- cardId: "MDExOlByb2plY3RDYXJkMzUxNzI2MjM=",
55- columnId: "MDEzOlByb2plY3RDb2x1bW44NDU0MzQ5"
56- }) { clientMutationId } }`
53+ moveProjectCard( input: {
54+ cardId: "MDExOlByb2plY3RDYXJkMzUxNzI2MjM=",
55+ columnId: "MDEzOlByb2plY3RDb2x1bW44NDU0MzQ5"
56+ }) { clientMutationId } }`
57+ ] ) ;
58+ } ) ;
59+
60+ test ( 'generateMutationQuery delete the card when it is in the project already' , t => {
61+ t . deepEqual ( generateMutationQuery ( moveData , project , column , nodeId , 'delete' ) , [
62+ `mutation {
63+ deleteProjectCard( input: {
64+ cardId: "MDExOlByb2plY3RDYXJkMzUxNzI2MjM="
65+ }) { clientMutationId } }`
5766 ] ) ;
5867} ) ;
5968
@@ -91,15 +100,65 @@ const addData = {
91100} ;
92101
93102test ( 'generateMutationQuery add the card when the card does not exist in the project' , t => {
94- t . deepEqual ( generateMutationQuery ( addData , project , column , nodeId ) , [
103+ t . deepEqual ( generateMutationQuery ( addData , project , column , nodeId , 'update' ) , [
95104 `mutation {
96- addProjectCard( input: {
97- contentId: "MDU6SXNzdWU1ODc4NzU1Mjk=",
98- projectColumnId: "MDEzOlByb2plY3RDb2x1bW44NDU0MzQ5"
99- }) { clientMutationId } }`
105+ addProjectCard( input: {
106+ contentId: "MDU6SXNzdWU1ODc4NzU1Mjk=",
107+ projectColumnId: "MDEzOlByb2plY3RDb2x1bW44NDU0MzQ5"
108+ }) { clientMutationId } }`
100109 ] ) ;
101110} ) ;
102111
112+ test ( 'generateMutationQuery skip issue deletion when the card does not exist in the project' , t => {
113+ t . deepEqual ( generateMutationQuery ( addData , project , column , nodeId , 'delete' ) , [ ] ) ;
114+ } ) ;
115+
116+ const archiveData = {
117+ projectCards : {
118+ nodes : [
119+ {
120+ id : 'MDExOlByb2plY3RDYXJkMzUxNzI2MjM=' ,
121+ isArchived : true ,
122+ project : {
123+ name : project ,
124+ id : 'MDc6UHJvamVjdDQwNzU5MDI='
125+ }
126+ }
127+ ]
128+ } ,
129+ repository : {
130+ projects : {
131+ nodes : [
132+ {
133+ name : project ,
134+ id : 'MDc6UHJvamVjdDQwNzU5MDI=' ,
135+ columns : {
136+ nodes : [
137+ {
138+ id : 'MDEzOlByb2plY3RDb2x1bW44NDU0MzQ5' ,
139+ name : column
140+ } ,
141+ {
142+ id : 'MDEzOlByb2plY3RDb2x1bW44MjUxOTAz' ,
143+ name : 'In progress'
144+ }
145+ ]
146+ }
147+ }
148+ ]
149+ } ,
150+ owner : {
151+ projects : {
152+ nodes : [ ]
153+ }
154+ }
155+ }
156+ } ;
157+
158+ test ( 'generateMutationQuery skip issue archive when the card is already archived' , t => {
159+ t . deepEqual ( generateMutationQuery ( archiveData , project , column , nodeId , 'archive' ) , [ ] ) ;
160+ } ) ;
161+
103162const dataNoColumn = {
104163 projectCards : {
105164 nodes : [ ]
0 commit comments