-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add mutation types * feat: mutations * fix: add properties check to address failing integ test * chore: update types and remove replacing flat call with flatMap Co-authored-by: Alexander Harris <alharris@amazon.com>
- Loading branch information
1 parent
1c50120
commit 04b3d27
Showing
16 changed files
with
751 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/codegen-ui-react/lib/__tests__/workflow/__snapshots__/mutation.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`getActionStateParameters basic 1`] = ` | ||
Array [ | ||
Object { | ||
"componentName": "ColoredBox", | ||
"property": "backgroundColor", | ||
"set": Object { | ||
"value": "something", | ||
}, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`getComponentStateReferences basic 1`] = ` | ||
Array [ | ||
Object { | ||
"componentName": "UserNameTextField", | ||
"property": "value", | ||
}, | ||
] | ||
`; |
95 changes: 95 additions & 0 deletions
95
packages/codegen-ui-react/lib/__tests__/workflow/mutation.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). | ||
You may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
import { MutationAction, DataStoreUpdateItemAction } from '@aws-amplify/codegen-ui'; | ||
import { getComponentStateReferences, getActionStateParameters } from '../../workflow/mutation'; | ||
|
||
describe('getComponentStateReferences', () => { | ||
test('basic', () => { | ||
const clickEvent: DataStoreUpdateItemAction = { | ||
action: 'Amplify.DataStoreUpdateItemAction', | ||
parameters: { | ||
model: 'Customer', | ||
id: { | ||
value: 'd9887268-47dd-4899-9568-db5809218751', | ||
}, | ||
fields: { | ||
username: { | ||
componentName: 'UserNameTextField', | ||
property: 'value', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const component = { | ||
id: '1234-5678-9010', | ||
componentType: 'Flex', | ||
name: 'MyForm', | ||
properties: {}, | ||
bindingProperties: {}, | ||
children: [ | ||
{ | ||
componentType: 'TextField', | ||
name: 'UsernameTextField', | ||
properties: { | ||
label: { | ||
value: 'Username', | ||
}, | ||
value: { | ||
value: 'vizsla', | ||
}, | ||
}, | ||
bindingProperties: {}, | ||
}, | ||
{ | ||
componentType: 'Button', | ||
name: 'SubmitButton', | ||
properties: { | ||
label: { | ||
value: 'Username', | ||
}, | ||
value: { | ||
value: 'vizsla', | ||
}, | ||
}, | ||
bindingProperties: {}, | ||
events: { | ||
click: clickEvent, | ||
}, | ||
}, | ||
], | ||
}; | ||
expect(getComponentStateReferences(component)).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('getActionStateParameters', () => { | ||
test('basic', () => { | ||
const action: MutationAction = { | ||
action: 'Amplify.Mutation', | ||
parameters: { | ||
state: { | ||
componentName: 'ColoredBox', | ||
property: 'backgroundColor', | ||
set: { | ||
value: 'something', | ||
}, | ||
}, | ||
}, | ||
}; | ||
expect(getActionStateParameters(action)).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.