@@ -39,6 +39,163 @@ describe('FileSystemEngineHost', () => {
39
39
expect ( schematic1 . description . name ) . toBe ( 'schematic1' ) ;
40
40
} ) ;
41
41
42
+ it ( 'lists schematics but not aliases' , ( ) => {
43
+ const engineHost = new FileSystemEngineHost ( root ) ;
44
+ const engine = new SchematicEngine ( engineHost ) ;
45
+
46
+ const testCollection = engine . createCollection ( 'aliases' ) ;
47
+ const names = testCollection . listSchematicNames ( ) ;
48
+
49
+ expect ( names ) . not . toBeNull ( ) ;
50
+ expect ( names [ 0 ] ) . toBe ( 'schematic1' ) ;
51
+ expect ( names [ 1 ] ) . toBe ( 'schematic2' ) ;
52
+ } ) ;
53
+
54
+ it ( 'extends a collection with string' , ( ) => {
55
+ const engineHost = new FileSystemEngineHost ( root ) ;
56
+ const engine = new SchematicEngine ( engineHost ) ;
57
+
58
+ const testCollection = engine . createCollection ( 'extends-basic-string' ) ;
59
+
60
+ expect ( testCollection . baseDescriptions ) . not . toBeUndefined ( ) ;
61
+ expect ( testCollection . baseDescriptions
62
+ && testCollection . baseDescriptions . length ) . toBe ( 1 ) ;
63
+
64
+ const schematic1 = engine . createSchematic ( 'schematic1' , testCollection ) ;
65
+
66
+ expect ( schematic1 ) . not . toBeNull ( ) ;
67
+ expect ( schematic1 . description . name ) . toBe ( 'schematic1' ) ;
68
+
69
+ const schematic2 = engine . createSchematic ( 'schematic2' , testCollection ) ;
70
+
71
+ expect ( schematic2 ) . not . toBeNull ( ) ;
72
+ expect ( schematic2 . description . name ) . toBe ( 'schematic2' ) ;
73
+
74
+ const names = testCollection . listSchematicNames ( ) ;
75
+
76
+ expect ( names . length ) . toBe ( 2 ) ;
77
+ } ) ;
78
+
79
+ it ( 'extends a collection with array' , ( ) => {
80
+ const engineHost = new FileSystemEngineHost ( root ) ;
81
+ const engine = new SchematicEngine ( engineHost ) ;
82
+
83
+ const testCollection = engine . createCollection ( 'extends-basic' ) ;
84
+
85
+ expect ( testCollection . baseDescriptions ) . not . toBeUndefined ( ) ;
86
+ expect ( testCollection . baseDescriptions
87
+ && testCollection . baseDescriptions . length ) . toBe ( 1 ) ;
88
+
89
+ const schematic1 = engine . createSchematic ( 'schematic1' , testCollection ) ;
90
+
91
+ expect ( schematic1 ) . not . toBeNull ( ) ;
92
+ expect ( schematic1 . description . name ) . toBe ( 'schematic1' ) ;
93
+
94
+ const schematic2 = engine . createSchematic ( 'schematic2' , testCollection ) ;
95
+
96
+ expect ( schematic2 ) . not . toBeNull ( ) ;
97
+ expect ( schematic2 . description . name ) . toBe ( 'schematic2' ) ;
98
+
99
+ const names = testCollection . listSchematicNames ( ) ;
100
+
101
+ expect ( names . length ) . toBe ( 2 ) ;
102
+ } ) ;
103
+
104
+ it ( 'extends a collection with full depth' , ( ) => {
105
+ const engineHost = new FileSystemEngineHost ( root ) ;
106
+ const engine = new SchematicEngine ( engineHost ) ;
107
+
108
+ const testCollection = engine . createCollection ( 'extends-deep' ) ;
109
+
110
+ expect ( testCollection . baseDescriptions ) . not . toBeUndefined ( ) ;
111
+ expect ( testCollection . baseDescriptions
112
+ && testCollection . baseDescriptions . length ) . toBe ( 2 ) ;
113
+
114
+ const schematic1 = engine . createSchematic ( 'schematic1' , testCollection ) ;
115
+
116
+ expect ( schematic1 ) . not . toBeNull ( ) ;
117
+ expect ( schematic1 . description . name ) . toBe ( 'schematic1' ) ;
118
+
119
+ const schematic2 = engine . createSchematic ( 'schematic2' , testCollection ) ;
120
+
121
+ expect ( schematic2 ) . not . toBeNull ( ) ;
122
+ expect ( schematic2 . description . name ) . toBe ( 'schematic2' ) ;
123
+
124
+ const names = testCollection . listSchematicNames ( ) ;
125
+
126
+ expect ( names . length ) . toBe ( 2 ) ;
127
+ } ) ;
128
+
129
+ it ( 'replaces base schematics when extending' , ( ) => {
130
+ const engineHost = new FileSystemEngineHost ( root ) ;
131
+ const engine = new SchematicEngine ( engineHost ) ;
132
+
133
+ const testCollection = engine . createCollection ( 'extends-replace' ) ;
134
+
135
+ expect ( testCollection . baseDescriptions ) . not . toBeUndefined ( ) ;
136
+ expect ( testCollection . baseDescriptions
137
+ && testCollection . baseDescriptions . length ) . toBe ( 1 ) ;
138
+
139
+ const schematic1 = engine . createSchematic ( 'schematic1' , testCollection ) ;
140
+
141
+ expect ( schematic1 ) . not . toBeNull ( ) ;
142
+ expect ( schematic1 . description . name ) . toBe ( 'schematic1' ) ;
143
+ expect ( schematic1 . description . description ) . toBe ( 'replaced' ) ;
144
+
145
+ const names = testCollection . listSchematicNames ( ) ;
146
+
147
+ expect ( names ) . not . toBeNull ( ) ;
148
+ expect ( names . length ) . toBe ( 1 ) ;
149
+ } ) ;
150
+
151
+ it ( 'extends multiple collections' , ( ) => {
152
+ const engineHost = new FileSystemEngineHost ( root ) ;
153
+ const engine = new SchematicEngine ( engineHost ) ;
154
+
155
+ const testCollection = engine . createCollection ( 'extends-multiple' ) ;
156
+
157
+ expect ( testCollection . baseDescriptions ) . not . toBeUndefined ( ) ;
158
+ expect ( testCollection . baseDescriptions
159
+ && testCollection . baseDescriptions . length ) . toBe ( 4 ) ;
160
+
161
+ const schematic1 = engine . createSchematic ( 'schematic1' , testCollection ) ;
162
+
163
+ expect ( schematic1 ) . not . toBeNull ( ) ;
164
+ expect ( schematic1 . description . name ) . toBe ( 'schematic1' ) ;
165
+ expect ( schematic1 . description . description ) . toBe ( 'replaced' ) ;
166
+
167
+ const schematic2 = engine . createSchematic ( 'schematic2' , testCollection ) ;
168
+
169
+ expect ( schematic2 ) . not . toBeNull ( ) ;
170
+ expect ( schematic2 . description . name ) . toBe ( 'schematic2' ) ;
171
+
172
+ const names = testCollection . listSchematicNames ( ) ;
173
+
174
+ expect ( names ) . not . toBeNull ( ) ;
175
+ expect ( names . length ) . toBe ( 2 ) ;
176
+ } ) ;
177
+
178
+ it ( 'errors on simple circular collections' , ( ) => {
179
+ const engineHost = new FileSystemEngineHost ( root ) ;
180
+ const engine = new SchematicEngine ( engineHost ) ;
181
+
182
+ expect ( ( ) => engine . createCollection ( 'extends-circular' ) ) . toThrow ( ) ;
183
+ } ) ;
184
+
185
+ it ( 'errors on complex circular collections' , ( ) => {
186
+ const engineHost = new FileSystemEngineHost ( root ) ;
187
+ const engine = new SchematicEngine ( engineHost ) ;
188
+
189
+ expect ( ( ) => engine . createCollection ( 'extends-circular-multiple' ) ) . toThrow ( ) ;
190
+ } ) ;
191
+
192
+ it ( 'errors on deep circular collections' , ( ) => {
193
+ const engineHost = new FileSystemEngineHost ( root ) ;
194
+ const engine = new SchematicEngine ( engineHost ) ;
195
+
196
+ expect ( ( ) => engine . createCollection ( 'extends-circular-deep' ) ) . toThrow ( ) ;
197
+ } ) ;
198
+
42
199
it ( 'errors on invalid aliases' , ( ) => {
43
200
const engineHost = new FileSystemEngineHost ( root ) ;
44
201
const engine = new SchematicEngine ( engineHost ) ;
0 commit comments