-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat(formatPkg): add .js to alternative names #383
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -25,10 +25,10 @@ it('keeps .bin intact', () => { | |
); | ||
const formatted = formatPkg(createInstantSearchApp); | ||
expect(formatted.bin).toMatchInlineSnapshot(` | ||
Object { | ||
"create-instantsearch-app": "src/cli/index.js", | ||
} | ||
`); | ||
Object { | ||
"create-instantsearch-app": "src/cli/index.js", | ||
} | ||
`); | ||
}); | ||
|
||
it('truncates long readmes', () => { | ||
|
@@ -223,7 +223,7 @@ describe('adds TypeScript information', () => { | |
}); | ||
}); | ||
|
||
describe('test getRepositoryInfo', () => { | ||
describe('getRepositoryInfo', () => { | ||
const getRepositoryInfo = formatPkg.__RewireAPI__.__get__( | ||
'getRepositoryInfo' | ||
); | ||
|
@@ -377,3 +377,67 @@ describe('test getRepositoryInfo', () => { | |
expect(getRepositoryInfo('aaaaaaaa')).toBe(null); | ||
}); | ||
}); | ||
|
||
describe('alternative names', () => { | ||
test('name not yet ending in .js', () => { | ||
const original = { | ||
name: 'places', | ||
lastPublisher: { name: 'unknown' }, | ||
}; | ||
expect(formatPkg(original)._searchInternal.alternativeNames) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
"places", | ||
"places.js", | ||
] | ||
`); | ||
}); | ||
|
||
test('name ending in .js', () => { | ||
const original = { | ||
name: 'places.js', | ||
lastPublisher: { name: 'unknown' }, | ||
}; | ||
expect(formatPkg(original)._searchInternal.alternativeNames) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
"placesjs", | ||
"places js", | ||
"places", | ||
"places.js", | ||
] | ||
`); | ||
}); | ||
|
||
test('scoped package', () => { | ||
const original = { | ||
name: '@algolia/places.js', | ||
lastPublisher: { name: 'unknown' }, | ||
}; | ||
expect(formatPkg(original)._searchInternal.alternativeNames) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
"algoliaplacesjs", | ||
" algolia places js", | ||
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. maybe a 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. yes, however it isn't really an issue for the engine, so I left it as-is |
||
"@algolia/places", | ||
"@algolia/places.js", | ||
] | ||
`); | ||
}); | ||
|
||
test('name with - and _', () => { | ||
const original = { | ||
name: 'this-is_a-dumb-name', | ||
lastPublisher: { name: 'unknown' }, | ||
}; | ||
expect(formatPkg(original)._searchInternal.alternativeNames) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
"thisisadumbname", | ||
"this is a dumb name", | ||
"this-is_a-dumb-name.js", | ||
"this-is_a-dumb-name", | ||
] | ||
`); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If you are specifically testing
getAlternativeNames
you could use this function directly, that way the test would be clear about the expectation. You already have snapshot in place to be sure that this function is already called in the main method.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.
good point, but would leave it for a major reorganise, since these functions aren't exported :)