@financial-times/dotcom-server-handlebars 8.2.1 → 8.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-server-handlebars",
3
- "version": "8.2.1",
3
+ "version": "8.2.3",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "types": "src/index.ts",
@@ -80,20 +80,21 @@ describe('dotcom-server-handlebars/src/PageKitHandlebars', () => {
80
80
  })
81
81
 
82
82
  describe('.renderView()', () => {
83
- it('can render a template and fire a callback with the result', () => {
84
- return new Promise((done) => {
85
- const templateContext = { title: 'Hello World', aside: 'Lorem ipsum' }
83
+ it('can render a template and fire a callback with the result', async () => {
84
+ const spy = jest.fn()
85
+ const templateContext = { title: 'Hello World', aside: 'Lorem ipsum' }
86
+ await instance.renderView(view, templateContext, spy)
86
87
 
87
- instance.renderView(view, templateContext, (error, result) => {
88
- expect(error).toBeNull()
88
+ const callbackParameters = spy.mock.calls[0]
89
+ const [callbackError, callbackSuccess] = callbackParameters
89
90
 
90
- expect(result).toContain('<h1>Hello World</h1>')
91
- expect(result).toContain('<aside>Lorem ipsum</aside>')
92
- expect(result).toMatch(/<main>.+<\/main>/s)
91
+ expect(spy).toHaveBeenCalledTimes(1)
93
92
 
94
- done()
95
- })
96
- })
93
+ expect(callbackError).toBeNull()
94
+
95
+ expect(callbackSuccess).toContain('<h1>Hello World</h1>')
96
+ expect(callbackSuccess).toContain('<aside>Lorem ipsum</aside>')
97
+ expect(callbackSuccess).toContain('<main>')
97
98
  })
98
99
  })
99
100
  })
@@ -30,5 +30,6 @@ export default function renderReactComponent({ hash }) {
30
30
 
31
31
  const props = { ...this, ...hash }
32
32
 
33
+ // @ts-ignore
33
34
  return ReactDOMServer.renderToStaticMarkup(React.createElement(Component, props))
34
35
  }