Skip to content

Commit

Permalink
new client test prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Autre31415 committed May 1, 2017
1 parent 4f135ec commit c12ff12
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 222 deletions.
8 changes: 6 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function(config) {
'test/models/*.js',
'node_modules/chai/chai.js',
'node_modules/chai-string/chai-string.js',
{pattern: 'test/templates/**/*', included: false},
'test/templates/**/*',
'test/*.js',
'test/client.html'
],
Expand All @@ -19,7 +19,11 @@ module.exports = function(config) {
'/templates/': '/base/test/templates/',
},
preprocessors: {
'teddy.js': ['coverage']
'teddy.js': ['coverage'],
'test/templates/**/*': ['html2js']
},
html2JsPreprocessor: {
stripPrefix: 'test/templates/'
},
coverageReporter: {
type: 'lcov',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"karma-coverage": "1.1.1",
"karma-chrome-launcher": "2.0.0",
"karma-coverage-allsources": "0.0.4",
"lcov-result-merger": "^1.2.0"
"lcov-result-merger": "^1.2.0",
"karma-html2js-preprocessor": "1.1.0"
},
"eslintConfig": {
"env": {
Expand Down
127 changes: 3 additions & 124 deletions test/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,130 +339,9 @@ <h2>Warning: these tests can only be run from a web server.</h2>

<!-- run tests -->
<script>
var assert = chai.assert,
templateList,
templateLength,
counter = 0,
crossOriginError,
i;

templateList = [
'conditionals/and.html',
'conditionals/andOr.html',
'conditionals/andTruthTable.html',
'conditionals/if.html',
'conditionals/ifElse.html',
'conditionals/ifElseIf.html',
'conditionals/ifElseValue.html',
'conditionals/ifEmptyArray.html',
'conditionals/ifEscapeRegex.html',
'conditionals/ifNotPresent.html',
'conditionals/ifValue.html',
'conditionals/nestedConditional.html',
'conditionals/not.html',
'conditionals/oneLine.html',
'conditionals/oneLineEmpty.html',
'conditionals/oneLineFalse.html',
'conditionals/oneLineMulti.html',
'conditionals/oneLineTrueOnly.html',
'conditionals/oneLineValue.html',
'conditionals/oneLineValueWithAdditionalAttributesNotImpactedByIf.html',
'conditionals/orSameVar.html',
'conditionals/orTruthTable.html',
'conditionals/unless.html',
'conditionals/unlessElse.html',
'conditionals/unlessElseUnless.html',
'conditionals/unlessElseValue.html',
'conditionals/unlessNull.html',
'conditionals/unlessValue.html',
'conditionals/xor.html',
'conditionals/duplicateVarInline.html',
'conditionals/duplicateOperatorInline.html',
'conditionals/ifElseRegex.html',
'conditionals/ifNestedProperties.html',
'includes/argVariableWithinArg.html',
'includes/conditionArgInStyle.html',
'includes/dynamicInclude.html',
'includes/include.html',
'includes/includeLoopsAndVars.html',
'includes/includeWithArguments.html',
'includes/nestedInclude.html',
'includes/nestedIncludeWithArg.html',
'includes/nestedLoop.html',
'includes/numericArgument.html',
'includes/numericVarInArg.html',
'includes/orphanedArgument.html',
'includes/inlineScriptTag.html',
'includes/argRedefineModelVar.html',
'includes/includeEscapeRegex.html',
'includes/invalidIncludeMarkup.html',
'includes/includeInfiniteLoop.html',
'looping/emptyMarkupLoop.html',
'looping/largeDataSet.html',
'looping/loopArrayOfObjects.html',
'looping/loopKeyVal.html',
'looping/loopVal.html',
'looping/nestedArrays.html',
'looping/nestedLoops.html',
'looping/nestedObjectLoop.html',
'looping/noMarkupLoop.html',
'looping/numericalVal.html',
'looping/undefinedObjectLoop.html',
'looping/camelCaseLoopVal.html',
'looping/loopInvalidAttributes.html',
'misc/markupArgument.html',
'misc/multipleVariables.html',
'misc/nestedVars.html',
'misc/numericMarkupArgument.html',
'misc/objectDoesNotExist.html',
'misc/plainHTML.html',
'misc/regexEscaping.html',
'misc/serverSideComments.html',
'misc/serverSideCommentsNested.html',
'misc/styleVariables.html',
'misc/templateWithLoop.html',
'misc/varEscaping.html',
'misc/varNoEscaping.html',
'misc/variable.html',
'misc/variableObjectProperty.html',
'misc/emptyModelMarkup.html',
'misc/infiniteIncludeTemplate.html',
'misc/varNotInModel.html',
'misc/templateToMinify.html'
];
templateLength = templateList.length;

// fetch and compile the templates
for (i = 0; i < templateLength; i++) {
(function(i) {
template = templateList[i];

var req = new XMLHttpRequest();
req.open('GET', 'templates/' + template);
req.send();

req.onreadystatechange = function() {
template = templateList[i];
if (req.readyState === XMLHttpRequest.DONE) {
if (req.status === 200) {
crossOriginError = document.getElementById('crossOriginError');
if (crossOriginError) {
crossOriginError.parentNode.removeChild(crossOriginError);
}
if (template === 'misc/templateToMinify.html') {
teddy.minify(true);
}
teddy.templates[template] = teddy.compile(req.response || req.responseText);
counter++;

if (counter === templateLength) {
mocha.run();
}
}
}
};
})(i);
}
var assert = chai.assert;
teddy.setVerbosity(0);
mocha.run();
</script>
</body>
</html>
Loading

0 comments on commit c12ff12

Please sign in to comment.