diff --git a/test/data/header.php b/test/data/header.php new file mode 100644 index 0000000..e2a57db --- /dev/null +++ b/test/data/header.php @@ -0,0 +1 @@ +
I am the header
\ No newline at end of file diff --git a/test/data/sub/content.php b/test/data/sub/content.php new file mode 100644 index 0000000..3f81e4a --- /dev/null +++ b/test/data/sub/content.php @@ -0,0 +1,5 @@ + + +I am the content
\ No newline at end of file diff --git a/test/execPHP.test.js b/test/execPHP.test.js index 4b9d48d..ab6a69a 100644 --- a/test/execPHP.test.js +++ b/test/execPHP.test.js @@ -8,7 +8,7 @@ const PHP = new ExecPHP() PHP.php = phpPath const mock_res = { - status: _status => { } + status: _status => {} } describe('parse from file', function () { @@ -16,4 +16,9 @@ describe('parse from file', function () { const html = await PHP.parseFile(path.join(__dirname, 'data/bonjour.php'), mock_res) expect(html).toContain(`Bonjour le monde!
`) }) + + it('should work with relative import paths', async () => { + const html = await PHP.parseFile(path.join(__dirname, 'data/sub/content.php'), mock_res) + expect(html.replace(/\r?\n/g, '')).toContain('I am the header
I am the content
') + }) })