Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move component-index generation to scaffold-config package (#2…
…1090) * chore: Move component-index generation to scaffold-config package * Review fixes * Fix review comments for realzies this time
- Loading branch information
Blue F
committed
Apr 20, 2022
1 parent
b8ba111
commit 10dfccc
Showing
6 changed files
with
88 additions
and
64 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import dedent from 'dedent' | ||
|
||
const componentIndexHtmlGenerator = (headModifier: string = '') => { | ||
return () => { | ||
const template = dedent` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>Components App</title> | ||
${headModifier} | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html> | ||
` | ||
|
||
// If the framework supplies an empty string for the modifier, | ||
// strip out the empty line | ||
return template.replace(/\n {4}\n/g, '\n') | ||
} | ||
} | ||
|
||
export default componentIndexHtmlGenerator |
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
46 changes: 46 additions & 0 deletions
46
packages/scaffold-config/test/unit/component-index-template.spec.ts
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,46 @@ | ||
import { expect } from 'chai' | ||
import dedent from 'dedent' | ||
import componentIndexHtmlGenerator from '../../src/component-index-template' | ||
|
||
describe('componentIndexHtmlGenerator', () => { | ||
it('strips spaces and newlines appropriately', () => { | ||
const generator = componentIndexHtmlGenerator() | ||
|
||
const expected = dedent` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>Components App</title> | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html>` | ||
|
||
expect(generator()).to.eq(expected) | ||
}) | ||
|
||
it('handles header modifier', () => { | ||
const generator = componentIndexHtmlGenerator('foobar') | ||
|
||
const expected = dedent` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>Components App</title> | ||
foobar | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html>` | ||
|
||
expect(generator()).to.eq(expected) | ||
}) | ||
}) |
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
10dfccc
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
10dfccc
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.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: