@@ -65,3 +65,69 @@ describe('ng-add', () => {
65
65
} ) ;
66
66
67
67
} ) ;
68
+
69
+ describe ( 'ng-add with yarn should generate a GitHub workflow' , ( ) => {
70
+
71
+ let initialTree : Tree ;
72
+
73
+ beforeEach ( ( ) => {
74
+ initialTree = Tree . empty ( ) ;
75
+ initialTree . create ( 'angular.json' , fs . readFileSync ( path . resolve ( __dirname , '..' , '..' , 'testing' , 'mocks' , 'angular.mocks.yarn.json' ) ) ) ;
76
+ } ) ;
77
+
78
+ it ( 'when no yarnrc.yml' , async ( ) => {
79
+ const runner = new SchematicTestRunner ( '@o3r/pipeline' , collectionPath ) ;
80
+ const tree = await runner . runSchematic ( 'ng-add' , {
81
+ toolchain : 'github'
82
+ } as NgAddSchematicsSchema , initialTree ) ;
83
+
84
+ expect ( tree . exists ( '.github/actions/setup/action.yml' ) ) . toBe ( true ) ;
85
+ expect ( tree . exists ( '.github/workflows/main.yml' ) ) . toBe ( true ) ;
86
+ expect ( tree . exists ( '.npmrc' ) ) . toBe ( false ) ;
87
+
88
+ expect ( tree . readText ( '.github/actions/setup/action.yml' ) ) . toContain ( '(yarn cache dir)' ) ;
89
+
90
+ } ) ;
91
+
92
+ it ( 'with yarnrc.yml without yarnPath' , async ( ) => {
93
+ const runner = new SchematicTestRunner ( '@o3r/pipeline' , collectionPath ) ;
94
+ initialTree . create ( '.yarnrc.yml' , '' ) ;
95
+ const tree = await runner . runSchematic ( 'ng-add' , {
96
+ toolchain : 'github'
97
+ } as NgAddSchematicsSchema , initialTree ) ;
98
+
99
+ expect ( tree . exists ( '.github/actions/setup/action.yml' ) ) . toBe ( true ) ;
100
+ expect ( tree . exists ( '.github/workflows/main.yml' ) ) . toBe ( true ) ;
101
+ expect ( tree . exists ( '.npmrc' ) ) . toBe ( false ) ;
102
+
103
+ expect ( tree . readText ( '.github/actions/setup/action.yml' ) ) . toContain ( '(yarn config get cacheFolder)' ) ;
104
+ } ) ;
105
+
106
+ it ( 'with yarnrc.yml with yarnPath v1' , async ( ) => {
107
+ const runner = new SchematicTestRunner ( '@o3r/pipeline' , collectionPath ) ;
108
+ initialTree . create ( '.yarnrc.yml' , 'yarnPath: .yarn/releases/yarn-1.2.3.cjs' ) ;
109
+ const tree = await runner . runSchematic ( 'ng-add' , {
110
+ toolchain : 'github'
111
+ } as NgAddSchematicsSchema , initialTree ) ;
112
+
113
+ expect ( tree . exists ( '.github/actions/setup/action.yml' ) ) . toBe ( true ) ;
114
+ expect ( tree . exists ( '.github/workflows/main.yml' ) ) . toBe ( true ) ;
115
+ expect ( tree . exists ( '.npmrc' ) ) . toBe ( false ) ;
116
+
117
+ expect ( tree . readText ( '.github/actions/setup/action.yml' ) ) . toContain ( '(yarn cache dir)' ) ;
118
+ } ) ;
119
+
120
+ it ( 'with yarnrc.yml with yarnPath v2' , async ( ) => {
121
+ const runner = new SchematicTestRunner ( '@o3r/pipeline' , collectionPath ) ;
122
+ initialTree . create ( '.yarnrc.yml' , 'yarnPath: .yarn/releases/yarn-3.2.1.cjs' ) ;
123
+ const tree = await runner . runSchematic ( 'ng-add' , {
124
+ toolchain : 'github'
125
+ } as NgAddSchematicsSchema , initialTree ) ;
126
+
127
+ expect ( tree . exists ( '.github/actions/setup/action.yml' ) ) . toBe ( true ) ;
128
+ expect ( tree . exists ( '.github/workflows/main.yml' ) ) . toBe ( true ) ;
129
+ expect ( tree . exists ( '.npmrc' ) ) . toBe ( false ) ;
130
+
131
+ expect ( tree . readText ( '.github/actions/setup/action.yml' ) ) . toContain ( '(yarn config get cacheFolder)' ) ;
132
+ } ) ;
133
+ } ) ;
0 commit comments