-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Showing
35 changed files
with
498 additions
and
392 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ npm-debug.log | |
sauce_connect.log* | ||
.idea | ||
yarn-error.log | ||
/handlebars-release.tgz |
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
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
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 @@ | ||
Add a new integration test by creating a new subfolder | ||
|
||
Add a file "test.sh" to that runs the test. "test.sh" should exit with a non-zero exit code | ||
and display an error message, if something goes wrong. | ||
|
||
* An integration test should reflect real-world setups that use handlebars. | ||
* It should compile a minimal template and compare the output to an expected output. | ||
* It should use "../.." as dependency for Handlebars so that the currently built library is used. | ||
|
||
Currently, integration tests are only running on Linux, especially in travis-ci. | ||
|
||
|
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 @@ | ||
module.exports = { | ||
"extends": "eslint:recommended", | ||
"globals": { | ||
"self": false | ||
}, | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
'no-console': 'off' | ||
} | ||
} |
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,2 @@ | ||
target | ||
package-lock.json |
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,16 @@ | ||
{ | ||
"name": "multi-nodejs-test", | ||
"version": "1.0.0", | ||
"description": "Simple integration test with all relevant NodeJS-versions.", | ||
"keywords": [], | ||
"author": "Nils Knappmeier", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"handlebars": "file:../.." | ||
}, | ||
"scripts": { | ||
"test": "node run-handlebars.js", | ||
"test-precompile": "handlebars precompile-test-template.txt.hbs" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integration-testing/multi-nodejs-test/precompile-test-template.txt.hbs
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 @@ | ||
Author: {{author}} |
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,11 @@ | ||
// This test should run successfully with node 0.10++ as long as Handlebars has been compiled before | ||
var assert = require('assert'); | ||
var Handlebars = require('handlebars'); | ||
|
||
console.log('Testing built Handlebars with Node version ' + process.version); | ||
|
||
var template = Handlebars.compile('Author: {{author}}'); | ||
var output = template({author: 'Yehuda'}); | ||
assert.strictEqual(output, 'Author: Yehuda'); | ||
|
||
console.log('Success'); |
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,13 @@ | ||
#!/bin/bash | ||
|
||
cd "$( dirname "$( readlink -f "$0" )" )" || exit 1 | ||
|
||
for i in */test.sh ; do | ||
( | ||
echo "----------------------------------------" | ||
echo "-- Running integration test: $i" | ||
echo "----------------------------------------" | ||
cd "$( dirname "$i" )" || exit 1 | ||
./test.sh || exit 1 | ||
) | ||
done |
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,3 @@ | ||
node_modules | ||
dist | ||
package-lock.json |
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,21 @@ | ||
{ | ||
"name": "webpack-test", | ||
"description": "Various tests with Handlebars and Webpack", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "webpack --config webpack.config.js", | ||
"test": "node dist/main.js" | ||
}, | ||
"private": true, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"handlebars": "file:../..", | ||
"handlebars-loader": "^1.7.1", | ||
"webpack": "^4.39.3", | ||
"webpack-cli": "^3.3.7" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
integration-testing/webpack-test/src/handlebars-default-import-pre-4.2-test.js
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,6 @@ | ||
import Handlebars from 'handlebars/dist/handlebars'; | ||
|
||
import {assertEquals} from './lib/assert'; | ||
|
||
const template = Handlebars.compile('Author: {{author}}'); | ||
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); |
6 changes: 6 additions & 0 deletions
6
integration-testing/webpack-test/src/handlebars-default-import-test.js
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,6 @@ | ||
import Handlebars from 'handlebars'; | ||
import {assertEquals} from './lib/assert'; | ||
|
||
|
||
const template = Handlebars.compile('Author: {{author}}'); | ||
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); |
8 changes: 8 additions & 0 deletions
8
integration-testing/webpack-test/src/handlebars-loader-test.js
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 @@ | ||
import {assertEquals} from './lib/assert'; | ||
|
||
import testTemplate from './test-template.handlebars'; | ||
assertEquals(testTemplate({author: 'Yehuda'}).trim(), 'Author: Yehuda'); | ||
|
||
|
||
const testTemplateRequire = require('./test-template.handlebars'); | ||
assertEquals(testTemplateRequire({author: 'Yehuda'}).trim(), 'Author: Yehuda'); |
6 changes: 6 additions & 0 deletions
6
integration-testing/webpack-test/src/handlebars-wildcard-import-pre-4.2-test.js
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,6 @@ | ||
import * as Handlebars from 'handlebars/dist/handlebars'; | ||
|
||
import {assertEquals} from './lib/assert'; | ||
|
||
const template = Handlebars.compile('Author: {{author}}'); | ||
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); |
5 changes: 5 additions & 0 deletions
5
integration-testing/webpack-test/src/handlebars-wildcard-import-test.js
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,5 @@ | ||
import * as Handlebars from 'handlebars'; | ||
import {assertEquals} from './lib/assert'; | ||
|
||
const template = Handlebars.compile('Author: {{author}}'); | ||
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); |
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,5 @@ | ||
export function assertEquals(actual, expected) { | ||
if (actual !== expected) { | ||
throw new Error(`Expected "${actual}" to equal "${expected}"`); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
integration-testing/webpack-test/src/test-template.handlebars
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,2 @@ | ||
Author: {{author}} | ||
|
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,16 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Cleanup: package-lock and "npm ci" is not working with local dependencies | ||
rm dist package-lock.json -rf | ||
npm install | ||
npm run build | ||
|
||
for i in dist/*-test.js ; do | ||
echo "----------------------" | ||
echo "-- Running $i" | ||
echo "----------------------" | ||
node "$i" | ||
echo "Success" | ||
done |
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,22 @@ | ||
const fs = require('fs'); | ||
|
||
const testFiles = fs.readdirSync('src'); | ||
const entryPoints = {}; | ||
testFiles | ||
.filter(file => file.match(/-test.js$/)) | ||
.forEach(file => { | ||
entryPoints[file] = `./src/${file}`; | ||
}); | ||
|
||
module.exports = { | ||
entry: entryPoints, | ||
output: { | ||
filename: '[name]', | ||
path: __dirname + '/dist' | ||
}, | ||
module: { | ||
rules: [ | ||
{test: /\.handlebars$/, loader: 'handlebars-loader'} | ||
] | ||
} | ||
}; |
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
Oops, something went wrong.