Skip to content

Commit

Permalink
test: add integ test for reserved keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Feb 28, 2022
1 parent f72a46b commit c9940ab
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const EXPECTED_SUCCESSFUL_CASES = new Set([
'DataStoreActionBindings',
'CreateModelWithComplexTypes',
'InitialValueBindings',
'DataBindingNamedClass',
]);
const EXPECTED_INVALID_INPUT_CASES = new Set([
'ComponentMissingProperties',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,10 @@ describe('Generated Components', () => {
cy.get('p.amplify-text').should('have.css', 'color', 'rgb(0, 128, 128)');
});
});

describe('Reserved Keywords', () => {
it('renders with reseverd keywords props', () => {
cy.get('#reserved-keywords').find('.amplify-text').should('have.text', 'biology');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useEffect, useState } from 'react';
import { AmplifyProvider } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';
import { DataStore } from 'aws-amplify';
import { User, Listing } from './models';
import { User, Listing, Class } from './models';
import {
ViewTest,
ViewWithButton,
Expand Down Expand Up @@ -58,6 +58,7 @@ import {
PaginatedCollection,
SearchableCollection,
ComponentWithAuthBinding,
DataBindingNamedClass,
} from './ui-components'; // eslint-disable-line import/extensions
import { initializeAuthMockData } from './mock-utils';

Expand Down Expand Up @@ -361,6 +362,9 @@ export default function ComponentTests() {
}}
/>
</div>
<div id="reserved-keywords">
<DataBindingNamedClass class={new Class({ name: 'biology' })} />
</div>
</AmplifyProvider>
);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
import { initSchema } from '@aws-amplify/datastore';
import { schema } from './schema';

const { UserPreference, User, Listing, ComplexModel } = initSchema(schema);
const { UserPreference, User, Listing, ComplexModel, Class } = initSchema(schema);

export { UserPreference, User, Listing, ComplexModel };
export { UserPreference, User, Listing, ComplexModel, Class };
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,44 @@ export const schema = {
},
],
},
Class: {
name: 'Class',
fields: {
id: {
name: 'id',
isArray: false,
type: 'ID',
isRequired: true,
attributes: [],
},
name: {
name: 'name',
isArray: false,
type: 'String',
isRequired: false,
attributes: [],
},
},
syncable: true,
pluralName: 'Classes',
attributes: [
{
type: 'model',
properties: {},
},
{
type: 'auth',
properties: {
rules: [
{
allow: 'public',
operations: ['create', 'update', 'delete', 'read'],
},
],
},
},
],
},
},
enums: {},
nonModels: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "1234-5678-9010",
"componentType": "Text",
"name": "DataBindingNamedClass",
"bindingProperties": {
"class": {
"type": "Data",
"bindingProperties": {
"model": "Class"
}
}
},
"properties": {
"label": {
"bindingProperties": {
"property": "class",
"field": "name"
}
}
},
"schemaVersion": "1.0"
}
16 changes: 16 additions & 0 deletions packages/test-generator/lib/components/bindings/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
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.
*/
export { default as DataBindingNamedClass } from './dataBindingNamedClass.json';
16 changes: 16 additions & 0 deletions packages/test-generator/lib/components/bindings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
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.
*/
export * from './data';
1 change: 1 addition & 0 deletions packages/test-generator/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ export * from './errors';
export * from './variants';
export * from './golden-files';
export * from './workflow';
export * from './bindings';

0 comments on commit c9940ab

Please sign in to comment.