forked from primer/octicons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(octicons_react): update package deps and tests (primer#838)
* refactor(octicons_react): update package deps and tests * chore: update jest config * chore: fix eslint warnings * chore: rename PublicAPI to public-api * test(tree-shaking): update tests to include single import
- Loading branch information
Showing
12 changed files
with
3,408 additions
and
4,639 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
231 changes: 231 additions & 0 deletions
231
lib/octicons_react/__tests__/__snapshots__/public-api.test.js.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,231 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`@primer/octicons-react should not update exports without a semver change 1`] = ` | ||
[ | ||
"AlertIcon", | ||
"ArchiveIcon", | ||
"ArrowBothIcon", | ||
"ArrowDownIcon", | ||
"ArrowDownLeftIcon", | ||
"ArrowDownRightIcon", | ||
"ArrowLeftIcon", | ||
"ArrowRightIcon", | ||
"ArrowSwitchIcon", | ||
"ArrowUpIcon", | ||
"ArrowUpLeftIcon", | ||
"ArrowUpRightIcon", | ||
"BeakerIcon", | ||
"BellFillIcon", | ||
"BellIcon", | ||
"BellSlashIcon", | ||
"BoldIcon", | ||
"BookIcon", | ||
"BookmarkFillIcon", | ||
"BookmarkIcon", | ||
"BookmarkSlashFillIcon", | ||
"BookmarkSlashIcon", | ||
"BriefcaseIcon", | ||
"BroadcastIcon", | ||
"BrowserIcon", | ||
"BugIcon", | ||
"CalendarIcon", | ||
"CheckCircleFillIcon", | ||
"CheckCircleIcon", | ||
"CheckIcon", | ||
"ChecklistIcon", | ||
"ChevronDownIcon", | ||
"ChevronLeftIcon", | ||
"ChevronRightIcon", | ||
"ChevronUpIcon", | ||
"CircleIcon", | ||
"CircleSlashIcon", | ||
"ClippyIcon", | ||
"ClockIcon", | ||
"CodeIcon", | ||
"CodeReviewIcon", | ||
"CodeSquareIcon", | ||
"CommentDiscussionIcon", | ||
"CommentIcon", | ||
"CommitIcon", | ||
"ContainerIcon", | ||
"CopyIcon", | ||
"CpuIcon", | ||
"CreditCardIcon", | ||
"CrossReferenceIcon", | ||
"DashIcon", | ||
"DatabaseIcon", | ||
"DesktopDownloadIcon", | ||
"DeviceCameraIcon", | ||
"DeviceCameraVideoIcon", | ||
"DeviceDesktopIcon", | ||
"DeviceMobileIcon", | ||
"DiffAddedIcon", | ||
"DiffIcon", | ||
"DiffIgnoredIcon", | ||
"DiffModifiedIcon", | ||
"DiffRemovedIcon", | ||
"DiffRenamedIcon", | ||
"DotFillIcon", | ||
"DotIcon", | ||
"DownloadIcon", | ||
"EllipsisIcon", | ||
"EyeClosedIcon", | ||
"EyeIcon", | ||
"FileBadgeIcon", | ||
"FileBinaryIcon", | ||
"FileCodeIcon", | ||
"FileDiffIcon", | ||
"FileDirectoryFillIcon", | ||
"FileDirectoryIcon", | ||
"FileIcon", | ||
"FileMediaIcon", | ||
"FileSubmoduleIcon", | ||
"FileSymlinkFileIcon", | ||
"FileZipIcon", | ||
"FilterIcon", | ||
"FlameIcon", | ||
"FoldDownIcon", | ||
"FoldIcon", | ||
"FoldUpIcon", | ||
"GearIcon", | ||
"GiftIcon", | ||
"GitBranchIcon", | ||
"GitCommitIcon", | ||
"GitCompareIcon", | ||
"GitForkIcon", | ||
"GitMergeIcon", | ||
"GitPullRequestIcon", | ||
"GlobeIcon", | ||
"GrabberIcon", | ||
"GraphIcon", | ||
"HeadingIcon", | ||
"HeartFillIcon", | ||
"HeartIcon", | ||
"HistoryIcon", | ||
"HomeFillIcon", | ||
"HomeIcon", | ||
"HorizontalRuleIcon", | ||
"HourglassIcon", | ||
"HubotIcon", | ||
"ImageIcon", | ||
"InboxIcon", | ||
"InfinityIcon", | ||
"InfoIcon", | ||
"InsightsIcon", | ||
"IssueClosedIcon", | ||
"IssueOpenedIcon", | ||
"IssueReopenedIcon", | ||
"ItalicIcon", | ||
"KebabHorizontalIcon", | ||
"KeyIcon", | ||
"LawIcon", | ||
"LightBulbIcon", | ||
"LinkExternalIcon", | ||
"LinkIcon", | ||
"ListOrderedIcon", | ||
"ListUnorderedIcon", | ||
"LocationIcon", | ||
"LockIcon", | ||
"LogoGistIcon", | ||
"LogoGithubIcon", | ||
"MailIcon", | ||
"MarkGithubIcon", | ||
"MarkdownIcon", | ||
"MegaphoneIcon", | ||
"MentionIcon", | ||
"MeterIcon", | ||
"MilestoneIcon", | ||
"MirrorIcon", | ||
"MoonIcon", | ||
"MortarBoardIcon", | ||
"MuteIcon", | ||
"NoEntryIcon", | ||
"NorthStarIcon", | ||
"NoteIcon", | ||
"NumberIcon", | ||
"OctofaceIcon", | ||
"OrganizationIcon", | ||
"PackageDependenciesIcon", | ||
"PackageDependentsIcon", | ||
"PackageIcon", | ||
"PaintbrushIcon", | ||
"PaperAirplaneIcon", | ||
"PencilIcon", | ||
"PeopleIcon", | ||
"PersonIcon", | ||
"PinIcon", | ||
"PlayIcon", | ||
"PlugIcon", | ||
"PlusCircleIcon", | ||
"PlusIcon", | ||
"ProjectIcon", | ||
"PulseIcon", | ||
"QuestionIcon", | ||
"QuoteIcon", | ||
"ReplyIcon", | ||
"RepoCloneIcon", | ||
"RepoForkedIcon", | ||
"RepoIcon", | ||
"RepoPullIcon", | ||
"RepoPushIcon", | ||
"RepoTemplateIcon", | ||
"ReportIcon", | ||
"RocketIcon", | ||
"RssIcon", | ||
"RubyIcon", | ||
"ScreenFullIcon", | ||
"ScreenNormalIcon", | ||
"SearchIcon", | ||
"ServerIcon", | ||
"ShareAndroidIcon", | ||
"ShareIcon", | ||
"ShieldCheckIcon", | ||
"ShieldIcon", | ||
"ShieldLockIcon", | ||
"ShieldXIcon", | ||
"SignInIcon", | ||
"SignOutIcon", | ||
"SkipIcon", | ||
"SmileyIcon", | ||
"SquareFillIcon", | ||
"SquareIcon", | ||
"SquirrelIcon", | ||
"StarFillIcon", | ||
"StarIcon", | ||
"StopIcon", | ||
"StopwatchIcon", | ||
"StrikethroughIcon", | ||
"SunIcon", | ||
"SyncIcon", | ||
"TabIcon", | ||
"TagIcon", | ||
"TasklistIcon", | ||
"TelescopeIcon", | ||
"TerminalIcon", | ||
"ThreeBarsIcon", | ||
"ThumbsdownIcon", | ||
"ThumbsupIcon", | ||
"ToolsIcon", | ||
"TrashIcon", | ||
"TrashcanIcon", | ||
"TriangleDownIcon", | ||
"TriangleLeftIcon", | ||
"TriangleRightIcon", | ||
"TriangleUpIcon", | ||
"TypographyIcon", | ||
"UnfoldIcon", | ||
"UnlockIcon", | ||
"UnmuteIcon", | ||
"UnverifiedIcon", | ||
"UploadIcon", | ||
"VerifiedIcon", | ||
"VersionsIcon", | ||
"VideoIcon", | ||
"WorkflowIcon", | ||
"XCircleFillIcon", | ||
"XCircleIcon", | ||
"XIcon", | ||
"ZapIcon", | ||
"default", | ||
] | ||
`; |
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,7 @@ | ||
const Octicons = require('@primer/octicons-react') | ||
|
||
describe('@primer/octicons-react', () => { | ||
it('should not update exports without a semver change', () => { | ||
expect(Object.keys(Octicons).sort()).toMatchSnapshot() | ||
}) | ||
}) |
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,49 @@ | ||
const commonjs = require('@rollup/plugin-commonjs') | ||
const {nodeResolve} = require('@rollup/plugin-node-resolve') | ||
const {rollup} = require('rollup') | ||
const virtual = require('@rollup/plugin-virtual') | ||
|
||
test('tree shaking', async () => { | ||
const bundle = await rollup({ | ||
input: '__entrypoint__', | ||
external: [], | ||
plugins: [ | ||
nodeResolve(), | ||
commonjs(), | ||
virtual({ | ||
__entrypoint__: `import { AlertIcon } from '@primer/octicons-react'` | ||
}) | ||
], | ||
onwarn: ({code, message}) => { | ||
if (code !== 'EMPTY_BUNDLE') { | ||
throw new Error(message) | ||
} | ||
} | ||
}) | ||
const {output} = await bundle.generate({ | ||
format: 'esm' | ||
}) | ||
|
||
for (const {code} of output) { | ||
expect(code.trim()).toBe('') | ||
} | ||
}) | ||
|
||
test('tree shaking single export', async () => { | ||
const bundle = await rollup({ | ||
input: '__entrypoint__', | ||
external: ['react'], | ||
plugins: [ | ||
nodeResolve(), | ||
commonjs(), | ||
virtual({ | ||
__entrypoint__: `export { XIcon } from '@primer/octicons-react'` | ||
}) | ||
] | ||
}) | ||
const {output} = await bundle.generate({ | ||
format: 'esm' | ||
}) | ||
|
||
expect(`${Buffer.byteLength(output[0].code.trim()) / 1000}kB`).toMatchInlineSnapshot(`"2.345kB"`) | ||
}) |
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,20 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: 'current' | ||
} | ||
} | ||
], | ||
'@babel/preset-react' | ||
], | ||
env: { | ||
production: { | ||
presets: ['next/babel'] | ||
} | ||
} | ||
} |
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,11 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
moduleNameMapper: { | ||
'^rollup$': require.resolve('rollup') | ||
}, | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.(mjs|cjs|js|jsx)$': require.resolve('babel-jest') | ||
} | ||
} |
Oops, something went wrong.