-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86df05b
commit b105d53
Showing
6 changed files
with
61 additions
and
8 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,12 @@ | ||
/* eslint-disable */ | ||
|
||
const React = require('react'); | ||
const { File } = require('../../../components'); | ||
|
||
module.exports = function() { | ||
return [ | ||
React.createElement(File, { name: 'file1.html' }, ['Content1']), | ||
undefined, | ||
React.createElement(File, { name: 'file2.html' }, ['Content2']) | ||
]; | ||
}; |
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,8 @@ | ||
/* eslint-disable */ | ||
|
||
const React = require('react'); | ||
const { File } = require('../../../components'); | ||
|
||
module.exports = function() { | ||
return React.createElement(File, { name: 'file.html' }, ['Content']); | ||
}; |
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 path from "path"; | ||
import { renderTemplate } from "../template"; | ||
import { TemplateRenderResult } from "../../types"; | ||
|
||
describe('renderTemplate', () => { | ||
test('should render a single File template', async () => { | ||
const filePath = path.resolve(__dirname, './file-tests/single-template.js'); | ||
const renderedContent = await renderTemplate(filePath, {} as any) as TemplateRenderResult; | ||
|
||
expect(typeof renderedContent).toEqual('object'); | ||
expect(renderedContent.content).toEqual('Content'); | ||
expect(renderedContent.metadata.fileName).toEqual('file.html'); | ||
}); | ||
|
||
test('should render an array of File templates', async () => { | ||
const filePath = path.resolve(__dirname, './file-tests/file-templates.js'); | ||
const renderedContent = await renderTemplate(filePath, {} as any) as TemplateRenderResult[]; | ||
|
||
expect(Array.isArray(renderedContent)).toEqual(true); | ||
expect(typeof renderedContent[0]).toEqual('object'); | ||
expect(renderedContent[0].content).toEqual('Content1'); | ||
expect(renderedContent[0].metadata.fileName).toEqual('file1.html'); | ||
expect(typeof renderedContent[1]).toEqual('object'); | ||
expect(renderedContent[1].content).toEqual('Content2'); | ||
expect(renderedContent[1].metadata.fileName).toEqual('file2.html'); | ||
}); | ||
}); |
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