Skip to content

Commit

Permalink
Merge pull request #139 from Autre31415/appveyor
Browse files Browse the repository at this point in the history
Add appveyor CI + More browsers for client tests
  • Loading branch information
kethinov authored May 11, 2017
2 parents 7588ca7 + eaa2b68 commit 28066f6
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- npm run test
- npm run test-firefox
after_success:
- istanbul cover ./node_modules/mocha/bin/_mocha
- karma start
- lcov-result-merger 'coverage/**/lcov.info' 'coverage/fullCoverage.info'
- cat ./coverage/fullCoverage.info | ./node_modules/.bin/coveralls
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Teddy templating engine
===
[![NPM version](https://badge.fury.io/js/teddy.png)](http://badge.fury.io/js/teddy) [![Dependency Status](https://gemnasium.com/kethinov/teddy.png)](https://gemnasium.com/kethinov/teddy) [![Gittip](http://img.shields.io/gittip/kethinov.png)](https://www.gittip.com/kethinov/) [![Build Status](https://travis-ci.org/kethinov/teddy.svg?branch=master)](https://travis-ci.org/kethinov/teddy) [![Coverage Status](https://coveralls.io/repos/github/kethinov/teddy/badge.svg?branch=master)](https://coveralls.io/github/kethinov/teddy?branch=master)
[![NPM version](https://badge.fury.io/js/teddy.png)](http://badge.fury.io/js/teddy) [![Dependency Status](https://gemnasium.com/kethinov/teddy.png)](https://gemnasium.com/kethinov/teddy) [![Gittip](http://img.shields.io/gittip/kethinov.png)](https://www.gittip.com/kethinov/) [![Build Status](https://travis-ci.org/kethinov/teddy.svg?branch=master)](https://travis-ci.org/kethinov/teddy) [![Build status](https://ci.appveyor.com/api/projects/status/6w5a9jbw2gsw16rs?svg=true)](https://ci.appveyor.com/project/kethinov/teddy) [![Coverage Status](https://coveralls.io/repos/github/kethinov/teddy/badge.svg?branch=master)](https://coveralls.io/github/kethinov/teddy?branch=master)

Teddy is the most readable and easy to learn templating language there is!

Expand Down Expand Up @@ -392,11 +392,11 @@ API documentation
===

- `teddy.compile(template)`: Compile a template by supplying either source code or a file name (in Node.js).
- Returns template source code with `{! teddy comments !}` removed.
- Populates `teddy.templates` with the new template in the format of `teddy.templates[path]: compiledSource`.
- Returns template source code with `{! teddy comments !}` removed.
- Populates `teddy.templates` with the new template in the format of `teddy.templates[path]: compiledSource`.
- `teddy.render(template, model)`: Render a template by supplying either source code or a file name (in Node.js).
- Returns fully rendered HTML.
- `teddy.setTemplateRoot(path)`: Set the location of your templates directory.
- `teddy.setTemplateRoot(path)`: Set the location of your templates directory.
- Default is the current directory.
- `teddy.setVerbosity(n)`: Sets the level of verbosity in Teddy's console logs. Call `teddy.setVerbosity(n)` where `n` equals one of the below values to change the default:
- `0`: No logging.
Expand All @@ -419,7 +419,7 @@ API documentation
- `teddy.setDefaultParams()`: Reset all params to default.
- `teddy.flushCache(template)`: Delete all the caches of a given template by supplying either its source code or a file name (in Node.js).
- `teddy.flushCache(template, model)`: Delete the cache of a specific template and model combination by supplying the template's source code or file name (in Node.js) along with the desired model to match.
- `teddy.maxPasses(n)`: Sets the maximum number of passes the parser can execute over your template. If this maximum is exceeded, Teddy will stop attempting to render the template. The limit exists to prevent the possibility of teddy producing infinite loops due to improperly coded templates.
- `teddy.maxPasses(n)`: Sets the maximum number of passes the parser can execute over your template. If this maximum is exceeded, Teddy will stop attempting to render the template. The limit exists to prevent the possibility of teddy producing infinite loops due to improperly coded templates.
- Default: 25000.
- `teddy.compileAtEveryRender(true/false)`: When this setting is enabled, Teddy will compile the template at each render rather than caching previous compiles.
- Default is false. *(Not recommended to enable in production for performance reasons.)*
Expand Down Expand Up @@ -448,7 +448,7 @@ git clone [email protected]:kethinov/teddy.git
cd teddy
```

Install dependencies for the server test:
Install dependencies for the tests:

```
npm i
Expand All @@ -459,3 +459,11 @@ Run tests:
```
npm test
```

The default `npm test` command runs the tests server-side in Node.js and client-side in Chrome. See below commands for other browsers:

```
npm run test-firefox
npm run test-ie
npm run test-safari
```
10 changes: 10 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "{build}"
install:
- node --version
- npm --version
- npm install
test_script:
- npm run test
- npm run test-firefox
- npm run test-ie
build: off
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
},
"devDependencies": {
"eslint": "3.19.0",
"mocha": "3.2.0",
"mocha": "3.3.0",
"chai": "3.5.0",
"chai-string": "1.3.0",
"istanbul": "0.4.5",
"mocha-lcov-reporter": "1.3.0",
"coveralls": "2.13.0",
"cross-env": "4.0.0",
"karma": "1.6.0",
"coveralls": "2.13.1",
"cross-env": "5.0.0",
"karma": "1.7.0",
"karma-cli": "1.0.1",
"karma-mocha": "1.3.0",
"karma-coverage": "1.1.1",
"karma-chrome-launcher": "2.0.0",
"karma-coverage-allsources": "0.0.4",
"lcov-result-merger": "^1.2.0",
"karma-chrome-launcher": "2.1.1",
"karma-firefox-launcher": "1.0.1",
"karma-safari-launcher": "1.0.0",
"karma-ie-launcher": "1.0.0",
"lcov-result-merger": "1.2.0",
"karma-html2js-preprocessor": "1.1.0",
"karma-spec-reporter": "0.0.31"
},
Expand Down Expand Up @@ -66,6 +68,10 @@
"test": "cross-env NODE_ENV=test npm run test-server && npm run test-client",
"test-server": "cross-env NODE_ENV=test mocha --recursive test",
"test-client": "karma start",
"test-chrome": "karma start --browsers Chrome",
"test-firefox": "karma start --browsers Firefox",
"test-ie": "karma start --browsers IE",
"test-safari": "karma start --browsers Safari",
"eslint": "eslint .",
"cover": "cross-env NODE_ENV=cover istanbul cover _mocha --recursive test",
"coverage": "npm run cover"
Expand Down
11 changes: 11 additions & 0 deletions test/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ if (typeof process === 'object') {
global.teddy = require('../teddy');
global.model = makeModel();
}
else {
var assert = chai.assert,
templates = window.__html__,
i;

teddy.setVerbosity(0);

for (i in templates) {
teddy.templates[i] = teddy.compile(templates[i]);
}
}

before(function() {
teddy.setTemplateRoot('test/templates');
Expand Down
24 changes: 6 additions & 18 deletions test/looping.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
var loopMs;

if (typeof process === 'object') {
loopMs = 50;
if (process.env.NODE_ENV === 'cover') {
loopMs = 600;
}
}
else {
loopMs = 600;
}

describe('Looping', function() {
it('should loop through {letters} correctly (looping/loopVal.html)', function(done) {
assert.equalIgnoreSpaces(teddy.render('looping/loopVal.html', model), '<p>a</p><p>b</p><p>c</p>');
Expand Down Expand Up @@ -56,7 +44,7 @@ describe('Looping', function() {
done();
});

it('should loop through same array of 5000 elements in < ' + loopMs + 'ms during second attempt due to caching (looping/largeDataSet.html)', function(done) {
it('should loop through same array of 5000 elements in < 700ms during second attempt due to caching (looping/largeDataSet.html)', function(done) {
var start, end, time;
start = new Date().getTime();

Expand All @@ -65,7 +53,7 @@ describe('Looping', function() {
end = new Date().getTime();
time = end - start;

assert.isAtMost(time, loopMs);
assert.isAtMost(time, 700);
done();
});

Expand All @@ -83,7 +71,7 @@ describe('Looping', function() {
done();
});

it('should loop through same array of 5000 elements in < ' + loopMs + 'ms during second attempt due to caching (looping/largeDataSet.html)', function(done) {
it('should loop through same array of 5000 elements in < 700ms during second attempt due to caching (looping/largeDataSet.html)', function(done) {
var start, end, time;
start = new Date().getTime();

Expand All @@ -92,7 +80,7 @@ describe('Looping', function() {
end = new Date().getTime();
time = end - start;

assert.isAtMost(time, loopMs);
assert.isAtMost(time, 700);
done();
});

Expand All @@ -110,7 +98,7 @@ describe('Looping', function() {
done();
});

it('should loop through same array of 5000 elements in < ' + loopMs + 'ms during second attempt due to caching (looping/largeDataSet.html)', function(done) {
it('should loop through same array of 5000 elements in < 700ms during second attempt due to caching (looping/largeDataSet.html)', function(done) {
var start, end, time;
start = new Date().getTime();

Expand All @@ -120,7 +108,7 @@ describe('Looping', function() {
time = end - start;

teddy.cacheRenders(false);
assert.isAtMost(time, loopMs);
assert.isAtMost(time, 700);
done();
});

Expand Down

0 comments on commit 28066f6

Please sign in to comment.