Skip to content

Fix bug in getElementType logic #525

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

Merged
merged 9 commits into from
May 20, 2024
Next Next commit
Update tests and command
  • Loading branch information
khiga8 committed May 16, 2024
commit ca7a3c3279581ebf85989870da9d64bb6214e61b
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint:eslint-docs": "npm run update:eslint-docs -- --check",
"lint:js": "eslint .",
"pretest": "mkdir -p node_modules/ && ln -fs $(pwd) node_modules/",
"test": "npm run eslint-check && npm run lint && mocha tests/**/*.js tests/",
"test": "npm run eslint-check && npm run lint && mocha tests/**/*.js tests/**/*.mjs",
Copy link
Contributor Author

@khiga8 khiga8 May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mjs tests don't actually seem to be running, since this update. Updating this glob seems to fix it.

"update:eslint-docs": "eslint-doc-generator"
},
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions tests/utils/get-element-type.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,15 @@ describe('getElementType', function () {
])
expect(getElementType({}, node)).to.equal('Box')
})

it('returns raw type when polymorphic prop is set to component, and not the mapped value', function () {
// <Box as={Link} />
const setting = mockSetting({
Box: 'div',
})

// eslint-disable-next-line no-undef
const node = mockJSXOpeningElement('Box', [mockJSXAttribute('as', Link)])
expect(getElementType(setting, node)).to.equal('Box')
})
})
Loading