diff --git a/lib/config.js b/lib/config.js index 2a15cbb..b44d879 100644 --- a/lib/config.js +++ b/lib/config.js @@ -37,7 +37,7 @@ module.exports = async options => { } if (options.data) { - newOptions.data = options.isFragment ? createDocument(options.data) : options.data + newOptions.data = options.isFragment ? createDocument(options.data, options.language ?? 'en') : options.data newOptions.method = 'post' if (!newOptions.headers['Content-Type']) { newOptions.headers['Content-Type'] = 'text/html; charset=utf-8' diff --git a/lib/create-document-from-fragment.js b/lib/create-document-from-fragment.js index d9cbf1d..8a70da9 100644 --- a/lib/create-document-from-fragment.js +++ b/lib/create-document-from-fragment.js @@ -1 +1 @@ -module.exports = fragment => `Document from fragment${fragment}` +module.exports = (fragment, lang = 'en') => `Document from fragment${fragment}` diff --git a/test/lib/create-document-from-fragment-test.js b/test/lib/create-document-from-fragment-test.js index 8b536aa..434c3ff 100644 --- a/test/lib/create-document-from-fragment-test.js +++ b/test/lib/create-document-from-fragment-test.js @@ -3,7 +3,7 @@ const createDocument = require('../../lib/create-document-from-fragment') tap.test('returns document from fragment', test => { const fragment = '

This is a fragment

' - const document = createDocument(fragment) + const document = createDocument(fragment, 'en') const expectedDocument = 'Document from fragment

This is a fragment

' tap.equal(document, expectedDocument, 'document is correct') test.end()