New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Cleaned up Vue code #2184
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@aws-amplify/ui-vue': patch | ||
--- | ||
|
||
Cleaned Vue code. Updated jest to latest. Added in JSX. Updated how editor displays interface in .vue files. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import { Authenticator } from '../dist'; | ||
import crypto from 'crypto'; | ||
|
||
// This is needed for jest to get crypto module needed by nanoid | ||
Object.defineProperty(global.self, 'crypto', { | ||
value: { | ||
getRandomValues: (arr: Array<unknown>) => crypto.randomBytes(arr.length), | ||
}, | ||
}); | ||
import Authenticator from '../src/components/authenticator.vue'; | ||
import { components } from '../global-spec'; | ||
import { render } from '@testing-library/vue'; | ||
|
||
describe('Authenticator', () => { | ||
it('Authenticator Exists', () => { | ||
const wrapper = mount(Authenticator); | ||
const wrapper = render(Authenticator, { | ||
global: { | ||
components, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To get vue to see all the components we have to add them in here. Since we are using |
||
}, | ||
}); | ||
|
||
expect(wrapper).toBeTruthy(); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import BaseWrapper from './src/components/primitives/base-wrapper.vue'; | ||
import BaseFooter from './src/components/primitives/base-footer.vue'; | ||
import BaseForm from './src/components/primitives/base-form.vue'; | ||
import BaseAlert from './src/components/primitives/base-alert.vue'; | ||
import BaseTwoTabItem from './src/components/primitives/base-two-tab-item.vue'; | ||
import BaseTwoTabs from './src/components/primitives/base-two-tabs.vue'; | ||
import BaseFieldSet from './src/components/primitives/base-field-set.vue'; | ||
import BaseHeading from './src/components/primitives/base-heading.vue'; | ||
import AmplifyButton from './src/components/primitives/amplify-button.vue'; | ||
|
||
export const components = { | ||
BaseWrapper, | ||
BaseFooter, | ||
BaseForm, | ||
AmplifyButton, | ||
BaseTwoTabItem, | ||
BaseTwoTabs, | ||
BaseAlert, | ||
BaseFieldSet, | ||
BaseHeading, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
verbose: true, | ||
moduleFileExtensions: ['js', 'ts', 'json', 'vue'], | ||
moduleFileExtensions: ['js', 'ts', 'json', 'vue', 'tsx'], | ||
modulePathIgnorePatterns: ['<rootDir>/dist/'], | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
'^.+\\.(ts)$': 'ts-jest', | ||
'^.+\\.(js|jsx)$': 'babel-jest', | ||
'^.+\\.vue$': 'vue-jest', | ||
'^.+\\.vue$': '@vue/vue3-jest', | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"strict": true, | ||
"jsx": "preserve", | ||
"importHelpers": true, | ||
"declaration": true, | ||
"declaration": false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this prevent type generation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our typescript d.ts generation still occurs with our vite
That way we still have typescript definition files being created. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Can we leave a comment here for future readers who may not have context in to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! I'll add a note There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
"moduleResolution": "node", | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to need to pin jest, because of an issue with different jest versions breaking different tests being run on our frameworks. However, our tests no longer need this.
And I won't be able to use the latest version of the vue3-jest library unless we update to jest 27.