@@ -13,6 +13,7 @@ describe('`like` and `itemOf`', function (){
13
13
14
14
describe ( 'using `like` in one of its exits' , function ( ) {
15
15
testMachineWithMocha ( ) . machine ( Machine . build ( {
16
+ identity : 'test' ,
16
17
inputs : { fullName : { example : 'Roger Rabbit' } } ,
17
18
exits : { success : { like : 'fullName' } } ,
18
19
fn : function ( inputs , exits ) { return exits . success ( 123 ) ; }
@@ -25,6 +26,7 @@ describe('`like` and `itemOf`', function (){
25
26
26
27
describe ( 'and referenced input is configured with an invalid (and incompatible) input value' , function ( ) {
27
28
testMachineWithMocha ( ) . machine ( Machine . build ( {
29
+ identity : 'test' ,
28
30
inputs : { fullName : { example : 'Roger Rabbit' } } ,
29
31
exits : { success : { like : 'fullName' } } ,
30
32
fn : function ( inputs , exits ) { return exits . success ( 123 ) ; }
@@ -38,6 +40,7 @@ describe('`like` and `itemOf`', function (){
38
40
it ( 'should not .build() the machine if an input refers to another input w/ a `like` or `itemOf` instead of an example' , function ( ) {
39
41
assert . throws ( function ( ) {
40
42
Machine . build ( {
43
+ identity : 'test' ,
41
44
inputs : {
42
45
fullName : { example : 'Roger Rabbit' } ,
43
46
firstName : { like : 'fullName' } ,
@@ -49,6 +52,7 @@ describe('`like` and `itemOf`', function (){
49
52
50
53
assert . throws ( function ( ) {
51
54
Machine . build ( {
55
+ identity : 'test' ,
52
56
inputs : {
53
57
nameParts : { example : [ 'Roger' ] } ,
54
58
firstName : { itemOf : 'fullName' } ,
@@ -60,80 +64,87 @@ describe('`like` and `itemOf`', function (){
60
64
} ) ;
61
65
} ) ;
62
66
63
- describe ( 'using `like` in one of its inputs' , function ( ) {
64
- testMachineWithMocha ( ) . machine ( Machine . build ( {
65
- inputs : {
66
- fullName : { example : 'Roger Rabbit' } ,
67
- firstName : { like : 'fullName' }
68
- } ,
69
- exits : { success : { example : '===' } } ,
70
- fn : function ( inputs , exits ) { return exits . success ( inputs . firstName ) ; }
71
- } ) )
72
- . use ( { firstName : 123 } )
73
- . expect ( {
74
- outcome : 'success' ,
75
- output : '123'
76
- } ) ;
67
+ // No longer supported:
68
+ // describe('using `like` in one of its inputs', function (){
69
+ // testMachineWithMocha().machine(Machine.build({
70
+ // identity: 'test',
71
+ // inputs: {
72
+ // fullName: { example: 'Roger Rabbit' },
73
+ // firstName: { like: 'fullName' }
74
+ // },
75
+ // exits: { success: { example: '===' } },
76
+ // fn: function (inputs, exits) { return exits.success(inputs.firstName); }
77
+ // }))
78
+ // .use({ firstName: 123 })
79
+ // .expect({
80
+ // outcome: 'success',
81
+ // output: '123'
82
+ // });
77
83
78
- describe ( 'and referenced input is configured with an invalid (and incompatible) input value' , function ( ) {
79
- testMachineWithMocha ( ) . machine ( Machine . build ( {
80
- inputs : {
81
- fullName : { example : 'Roger Rabbit' } ,
82
- firstName : { like : 'fullName' }
83
- } ,
84
- exits : { success : { example : '===' } } ,
85
- fn : function ( inputs , exits ) { return exits . success ( inputs . firstName ) ; }
86
- } ) )
87
- . use ( { firstName : 123 , fullName : [ ] } )
88
- . expect ( {
89
- outcome : 'error'
90
- } ) ;
91
- } ) ;
84
+ // describe('and referenced input is configured with an invalid (and incompatible) input value', function (){
85
+ // testMachineWithMocha().machine(Machine.build({
86
+ // identity: 'test',
87
+ // inputs: {
88
+ // fullName: { example: 'Roger Rabbit' },
89
+ // firstName: { like: 'fullName' }
90
+ // },
91
+ // exits: { success: { example: '===' } },
92
+ // fn: function (inputs, exits) { return exits.success(inputs.firstName); }
93
+ // }))
94
+ // .use({ firstName: 123, fullName: [] })
95
+ // .expect({
96
+ // outcome: 'error'
97
+ // });
98
+ // });
92
99
93
100
94
- it ( 'should not .build() the machine if an input refers to itself' , function ( ) {
95
- assert . throws ( function ( ) {
96
- Machine . build ( {
97
- inputs : {
98
- fullName : { example : 'Roger Rabbit' } ,
99
- firstName : { like : 'firstName' }
100
- } ,
101
- exits : { success : { example : '===' } } ,
102
- fn : function ( inputs , exits ) { return exits . error ( ) ; }
103
- } ) ;
104
- } ) ;
105
- } ) ;
101
+ // it('should not .build() the machine if an input refers to itself', function (){
102
+ // assert.throws(function (){
103
+ // Machine.build({
104
+ // identity: 'test',
105
+ // inputs: {
106
+ // fullName: { example: 'Roger Rabbit' },
107
+ // firstName: { like: 'firstName' }
108
+ // },
109
+ // exits: { success: { example: '===' } },
110
+ // fn: function (inputs, exits) { return exits.error(); }
111
+ // });
112
+ // });
113
+ // });
106
114
107
- it ( 'should not .build() the machine if an input refers to another input w/ a `like` or `itemOf` instead of an example' , function ( ) {
108
- assert . throws ( function ( ) {
109
- Machine . build ( {
110
- inputs : {
111
- fullName : { example : 'Roger Rabbit' } ,
112
- lastName : { like : 'firstName' } ,
113
- firstName : { like : 'fullName' }
114
- } ,
115
- exits : { success : { example : '===' } } ,
116
- fn : function ( inputs , exits ) { return exits . error ( ) ; }
117
- } ) ;
118
- } ) ;
115
+ // it('should not .build() the machine if an input refers to another input w/ a `like` or `itemOf` instead of an example', function (){
116
+ // assert.throws(function (){
117
+ // Machine.build({
118
+ // identity: 'test',
119
+ // inputs: {
120
+ // fullName: { example: 'Roger Rabbit' },
121
+ // lastName: { like: 'firstName' },
122
+ // firstName: { like: 'fullName' }
123
+ // },
124
+ // exits: { success: { example: '===' } },
125
+ // fn: function (inputs, exits) { return exits.error(); }
126
+ // });
127
+ // });
119
128
120
- assert . throws ( function ( ) {
121
- Machine . build ( {
122
- inputs : {
123
- namePieces : { example : [ 'Roger' ] } ,
124
- lastName : { itemOf : 'namePieces' } ,
125
- firstName : { like : 'lastName' }
126
- } ,
127
- exits : { success : { example : '===' } } ,
128
- fn : function ( inputs , exits ) { return exits . error ( ) ; }
129
- } ) ;
130
- } ) ;
131
- } ) ;
129
+ // assert.throws(function (){
130
+ // Machine.build({
131
+ // identity: 'test',
132
+ // inputs: {
133
+ // namePieces: { example: ['Roger'] },
134
+ // lastName: { itemOf: 'namePieces' },
135
+ // firstName: { like: 'lastName' }
136
+ // },
137
+ // exits: { success: { example: '===' } },
138
+ // fn: function (inputs, exits) { return exits.error(); }
139
+ // });
140
+ // });
141
+ // });
132
142
133
- } ) ;
143
+ // });
134
144
135
145
describe ( 'using `itemOf` in one of its exits' , function ( ) {
136
146
testMachineWithMocha ( ) . machine ( Machine . build ( {
147
+ identity : 'test' ,
137
148
inputs : {
138
149
fullName : { example : [ 'Roger' ] }
139
150
} ,
@@ -148,23 +159,35 @@ describe('`like` and `itemOf`', function (){
148
159
} ) ;
149
160
150
161
describe ( 'using `itemOf` in one of its inputs' , function ( ) {
151
- testMachineWithMocha ( ) . machine ( Machine . build ( {
152
- inputs : {
153
- fullName : { example : [ 'Roger' ] } ,
154
- firstName : { itemOf : 'fullName' }
155
- } ,
156
- exits : { success : { example : '===' } } ,
157
- fn : function ( inputs , exits ) { return exits . success ( inputs . firstName ) ; }
158
- } ) )
159
- . use ( { firstName : 123 } )
160
- . expect ( {
161
- outcome : 'success' ,
162
- output : '123'
162
+ it ( 'should no longer work!' , function ( ) {
163
+ try {
164
+ testMachineWithMocha ( ) . machine ( Machine . build ( {
165
+ identity : 'test' ,
166
+ inputs : {
167
+ fullName : { example : [ 'Roger' ] } ,
168
+ firstName : { itemOf : 'fullName' }
169
+ } ,
170
+ exits : { success : { example : '===' } } ,
171
+ fn : function ( inputs , exits ) { return exits . success ( inputs . firstName ) ; }
172
+ } ) )
173
+ . use ( { firstName : 123 } )
174
+ . expect ( {
175
+ outcome : 'success' ,
176
+ output : '123'
177
+ } ) ;
178
+ } catch ( err ) {
179
+ if ( err . name === 'ImplementationError' ) {
180
+ // ok that's what we expected.
181
+ }
182
+ else { throw err ; }
183
+ }
184
+ throw new Error ( 'should not have made it here' ) ;
163
185
} ) ;
164
186
} ) ;
165
187
166
188
describe ( 'using `like` in one of its contract\'s exits' , function ( ) {
167
189
testMachineWithMocha ( ) . machine ( Machine . build ( {
190
+ identity : 'test' ,
168
191
inputs : {
169
192
fullName : { example : 'Roger' } ,
170
193
getFullName : {
@@ -175,7 +198,7 @@ describe('`like` and `itemOf`', function (){
175
198
}
176
199
}
177
200
} ,
178
- exits : { success : { example : '===' } } ,
201
+ exits : { success : { outputExample : '===' } } ,
179
202
fn : function ( inputs , exits ) { return exits . success ( inputs . getFullName ( ) . execSync ( ) ) ; }
180
203
} ) )
181
204
. use ( {
@@ -191,6 +214,7 @@ describe('`like` and `itemOf`', function (){
191
214
192
215
describe ( 'using `like` in one of its contract\'s inputs' , function ( ) {
193
216
testMachineWithMocha ( ) . machine ( Machine . build ( {
217
+ identity : 'test' ,
194
218
inputs : {
195
219
fullName : { example : 'Roger' } ,
196
220
getFullName : {
@@ -218,6 +242,7 @@ describe('`like` and `itemOf`', function (){
218
242
219
243
describe ( 'using `itemOf` in one of its contract\'s exits' , function ( ) {
220
244
testMachineWithMocha ( ) . machine ( Machine . build ( {
245
+ identity : 'test' ,
221
246
inputs : {
222
247
fullName : { example : [ 'Roger' ] } ,
223
248
getFullName : {
@@ -244,6 +269,7 @@ describe('`like` and `itemOf`', function (){
244
269
245
270
describe ( 'using `itemOf` in one of its contract\'s inputs' , function ( ) {
246
271
testMachineWithMocha ( ) . machine ( Machine . build ( {
272
+ identity : 'test' ,
247
273
inputs : {
248
274
fullName : { example : [ 'Roger' ] } ,
249
275
getFullName : {
@@ -271,6 +297,7 @@ describe('`like` and `itemOf`', function (){
271
297
272
298
describe ( 'using `like` in one of its contract\'s inputs\' contract\'s exits' , function ( ) {
273
299
testMachineWithMocha ( ) . machine ( Machine . build ( {
300
+ identity : 'test' ,
274
301
inputs : {
275
302
fullName : { example : 'Roger' } ,
276
303
getFullName : {
@@ -312,6 +339,7 @@ describe('`like` and `itemOf`', function (){
312
339
313
340
describe ( 'using `like` in one of its contract\'s inputs\' contract\'s inputs' , function ( ) {
314
341
testMachineWithMocha ( ) . machine ( Machine . build ( {
342
+ identity : 'test' ,
315
343
inputs : {
316
344
fullName : { example : 'Roger' } ,
317
345
getFullName : {
@@ -354,6 +382,7 @@ describe('`like` and `itemOf`', function (){
354
382
355
383
describe ( 'using `itemOf` in one of its contract\'s inputs\' contract\'s exits' , function ( ) {
356
384
testMachineWithMocha ( ) . machine ( Machine . build ( {
385
+ identity : 'test' ,
357
386
inputs : {
358
387
fullName : { example : [ 'Roger' ] } ,
359
388
getFullName : {
@@ -395,6 +424,7 @@ describe('`like` and `itemOf`', function (){
395
424
396
425
describe ( 'using `itemOf` in one of its contract\'s inputs\' contract\'s inputs' , function ( ) {
397
426
testMachineWithMocha ( ) . machine ( Machine . build ( {
427
+ identity : 'test' ,
398
428
inputs : {
399
429
fullName : { example : [ 'Roger' ] } ,
400
430
getFullName : {
0 commit comments