-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace outdent with our own implementation (#117)
Currently we use the `outdent` package so that tests that involve writing multi-line strings to files look a bit nicer. This package doesn't play nice in an ESM context, and we actually already have equivalents in `normalizeWhitespaceString` and `buildChangelog` that we can use instead. So this commit removes `outdent` in favor of these helpers.
- Loading branch information
Showing
7 changed files
with
87 additions
and
106 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { withMonorepoProjectEnvironment } from '../tests/functional/helpers/with'; | ||
import { buildChangelog } from '../tests/functional/helpers/utils'; | ||
import { buildChangelog } from '../tests/helpers'; | ||
|
||
jest.setTimeout(10_000); | ||
|
||
|
@@ -474,23 +474,23 @@ describe('create-release-branch (functional)', () => { | |
'a', | ||
'CHANGELOG.md', | ||
buildChangelog(` | ||
## [Unreleased] | ||
## [Unreleased] | ||
[Unreleased]: https://github.com/example-org/example-repo | ||
[Unreleased]: https://github.com/example-org/example-repo | ||
`), | ||
); | ||
await environment.writeFileWithinPackage( | ||
'b', | ||
'CHANGELOG.md', | ||
buildChangelog(` | ||
## [Unreleased] | ||
## [Unreleased] | ||
## [1.0.0] | ||
### Added | ||
- Initial release | ||
## [1.0.0] | ||
### Added | ||
- Initial release | ||
[Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected] | ||
[1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected] | ||
[Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected] | ||
[1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected] | ||
`), | ||
); | ||
await environment.createCommit('Initial commit'); | ||
|
@@ -533,14 +533,14 @@ describe('create-release-branch (functional)', () => { | |
await environment.readFileWithinPackage('b', 'CHANGELOG.md'), | ||
).toStrictEqual( | ||
buildChangelog(` | ||
## [Unreleased] | ||
## [Unreleased] | ||
## [1.0.0] | ||
### Added | ||
- Initial release | ||
## [1.0.0] | ||
### Added | ||
- Initial release | ||
[Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected] | ||
[1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected] | ||
[Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected] | ||
[1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected] | ||
`), | ||
); | ||
}, | ||
|
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 |
---|---|---|
|
@@ -4,8 +4,7 @@ import { when } from 'jest-when'; | |
import * as autoChangelog from '@metamask/auto-changelog'; | ||
import { SemVer } from 'semver'; | ||
import { MockWritable } from 'stdio-mock'; | ||
import _outdent from 'outdent'; | ||
import { withSandbox } from '../tests/helpers'; | ||
import { buildChangelog, withSandbox } from '../tests/helpers'; | ||
import { | ||
buildMockPackage, | ||
buildMockProject, | ||
|
@@ -22,8 +21,6 @@ import * as fsModule from './fs'; | |
import * as packageManifestModule from './package-manifest'; | ||
import * as repoModule from './repo'; | ||
|
||
const outdent = _outdent({ trimTrailingNewline: false }); | ||
|
||
jest.mock('./package-manifest'); | ||
jest.mock('./repo'); | ||
|
||
|
@@ -471,20 +468,18 @@ describe('package', () => { | |
|
||
await fs.promises.writeFile( | ||
changelogPath, | ||
outdent` | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
## [Unreleased] | ||
### Uncategorized | ||
- Add \`isNewFunction\` ([#2](https://repo.url/compare/package/pull/2)) | ||
## [1.0.0] - 2020-01-01 | ||
### Changed | ||
- Something else | ||
[Unreleased]: https://repo.url/compare/[email protected] | ||
[1.0.0]: https://repo.url/releases/tag/[email protected] | ||
`, | ||
buildChangelog(` | ||
## [Unreleased] | ||
### Uncategorized | ||
- Add isNewFunction ([#2](https://repo.url/compare/package/pull/2)) | ||
## [1.0.0] - 2020-01-01 | ||
### Changed | ||
- Something else | ||
[Unreleased]: https://repo.url/compare/[email protected] | ||
[1.0.0]: https://repo.url/releases/tag/[email protected] | ||
`), | ||
); | ||
|
||
await updatePackage({ project, packageReleasePlan }); | ||
|
@@ -494,27 +489,23 @@ describe('package', () => { | |
'utf8', | ||
); | ||
|
||
expect(newChangelogContent).toBe(outdent` | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
expect(newChangelogContent).toBe( | ||
buildChangelog(` | ||
## [Unreleased] | ||
## [Unreleased] | ||
## [2.0.0] | ||
### Uncategorized | ||
- Add isNewFunction ([#2](https://repo.url/compare/package/pull/2)) | ||
## [2.0.0] | ||
### Uncategorized | ||
- Add \`isNewFunction\` ([#2](https://repo.url/compare/package/pull/2)) | ||
## [1.0.0] - 2020-01-01 | ||
### Changed | ||
- Something else | ||
## [1.0.0] - 2020-01-01 | ||
### Changed | ||
- Something else | ||
[Unreleased]: https://repo.url/compare/[email protected] | ||
[2.0.0]: https://repo.url/compare/[email protected]@2.0.0 | ||
[1.0.0]: https://repo.url/releases/tag/[email protected] | ||
`); | ||
[Unreleased]: https://repo.url/compare/[email protected] | ||
[2.0.0]: https://repo.url/compare/[email protected]@2.0.0 | ||
[1.0.0]: https://repo.url/releases/tag/[email protected] | ||
`), | ||
); | ||
}); | ||
}); | ||
|
||
|
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
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