Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Setup for testing #79

Merged
merged 11 commits into from
Oct 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@

"globals": {
"Mailer": true,
"Utils": true,
"juice": false,
"FlowRouter": false,
"Router": false,
"TemplateHelpers": true,
"SSR": false,
"Picker": false,
"Routing": true,
"Templates": true
"Picker": false
}
}
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PORT=3100
TEST_DRIVER=dispatch:mocha

lint:
@./node_modules/.bin/eslint .

test-package:
@meteor test-packages ./ --driver-package $(TEST_DRIVER) --once --port $(PORT)

test-app:
@cd example && npm test -- --port $(PORT) && cd -

test-app-watch:
@cd example && npm run test:watch -- --port $(PORT)

test-watch:
@TEST_WATCH=1 meteor test-packages ./ --driver-package $(TEST_DRIVER) --port $(PORT)

.PHONY: test, test-watch
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Meteor Emails

[![CircleCI](https://circleci.com/gh/lookback/meteor-emails.svg?style=shield)](https://circleci.com/gh/lookback/meteor-emails)

`lookback:emails` is a Meteor package that makes it easier to build, test and debug rich HTML emails.

Usually, building HTML emails yourself is tedious. On top of that, add the need for data integration and thus a template language (for sending out daily digest emails, for instance). We wanted a way to preview the email in the browser *with real data* in order to quickly iterate on the design, instead of alternating between code editor and email client.
Expand Down Expand Up @@ -562,22 +564,40 @@ route: {

PRs and help is welcomed.

## Develop
### Develop

Clone repo, and run:

```
npm install
```

to install dev dev dependencies. We're using ESLint for linting.
to install dev dev dependencies. We're using ESLint for linting. Lint with:

```
npm run lint
```

Run tests with:

```
npm test
```

or have test watching with:

```
npm run test:watch
```

You'll find tests in the `lib` directory along with the source files.

## Things to do
### Things to do

- [ ] Tests.

Also see [open issues](https://github.com/lookback/meteor-emails/issues).

***

Made by [Lookback](http://github.com/lookback)
Made by [Johan](http://johanbrook.com) in [Lookback](http://github.com/lookback)
17 changes: 17 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
machine:
node:
version: 5.8.0

dependencies:
cache_directories:
- "~/.meteor"
- "~/.npm"
override:
# -- CACHE METEOR --
# Restore the meteor symlink
- if [ -d ~/.meteor ]; then sudo ln -s ~/.meteor/meteor /usr/local/bin/meteor; fi
# Install Meteor (if not restored from cache)
- if [ ! -e ~/.meteor/meteor ]; then curl https://install.meteor.com | /bin/sh; fi
- npm install --no-progress
- meteor npm install --no-progress:
pwd: example
2 changes: 2 additions & 0 deletions example/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ notices-for-facebook-graph-api-2
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
14 changes: 9 additions & 5 deletions example/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

ecmascript
ecmascript@0.5.9
lookback:emails
#chrisbutler:[email protected]
meteor-base
meteor-base@1.0.4
blaze-html-templates
reload
reload@1.1.11
spacebars
kadira:flow-router
#iron:router
standard-minifier-css
standard-minifier-js
[email protected]
[email protected]

practicalmeteor:chai
dispatch:mocha
shell-server
2 changes: 1 addition & 1 deletion example/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[email protected].1.1
[email protected].2
113 changes: 60 additions & 53 deletions example/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,69 +1,76 @@
[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected].8_1
[email protected].6
[email protected].8_1
[email protected].9
[email protected].7
[email protected].10
[email protected]
[email protected]
[email protected]_1
[email protected]_1
[email protected]
[email protected]_1
[email protected]
[email protected]
dispatch:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected].10
[email protected].10
[email protected].7
[email protected].8
[email protected].9
[email protected].11
[email protected].11
[email protected].8
[email protected].9
[email protected].10
kadira:[email protected]
[email protected]
[email protected].13_1
[email protected].14
lookback:[email protected]
meteor@1.1.15_1
meteor@1.6.0
[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
minifier-css@1.1.12_1
minifier-js@1.1.12_1
[email protected].17
modules@0.6.4
modules-runtime@0.6.4_1
minifier-css@1.2.15
minifier-js@1.2.15
[email protected].18
modules@0.7.7
modules-runtime@0.7.7
[email protected]_1
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
practicalmeteor:[email protected]_1
practicalmeteor:[email protected]
[email protected]
[email protected]
[email protected]
[email protected].10
[email protected].10
[email protected].8
[email protected].11
[email protected].11
[email protected].9
[email protected]
sacha:[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]_1
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "example",
"version": "1.0.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "meteor test --driver-package dispatch:mocha --once --full-app",
"test:watch": "TEST_WATCH=1 meteor test --port 5012 --driver-package dispatch:mocha --full-app"
},
"author": "Johan Brook",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions example/server/lib/template-helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TemplateHelpers = {
export default {

enumerate(arr, limit, oxfordComma) {
if (arr) {
Expand All @@ -24,7 +24,7 @@ TemplateHelpers = {
let suffix = ' and ';

if (oxfordComma === true
|| (typeof oxfordComma === 'number' && length >= oxfordComma)) {
|| typeof oxfordComma === 'number' && length >= oxfordComma) {
suffix = `, ${suffix}`;
}

Expand Down
28 changes: 13 additions & 15 deletions example/server/lib/templates.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
Templates = {};
export default {
sample: {
path: 'sample-email/template.html', // Relative to the 'private' dir.
scss: 'sample-email/style.scss', // Mail specific SCSS.

Templates.sample = {
path: 'sample-email/template.html', // Relative to the 'private' dir.
scss: 'sample-email/style.scss', // Mail specific SCSS.
helpers: {
capitalizedName() {
return this.name.charAt(0).toUpperCase() + this.name.slice(1);
}
},

helpers: {
capitalizedName() {
return this.name.charAt(0).toUpperCase() + this.name.slice(1);
}
},

route: {
path: '/sample/:name',
data: function(params) {
return {
route: {
path: '/sample/:name',
data: (params) => ({
name: params.name,
names: ['Johan', 'John', 'Paul', 'Ringo']
};
})
}
}
};
29 changes: 29 additions & 0 deletions example/server/server.app-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-env mocha */
import { Mailer } from 'meteor/lookback:emails';
import { assert } from 'meteor/practicalmeteor:chai';

describe('Render email', () => {

it('should render an email', () => {
const string = Mailer.render('sample', {
name: 'johan',
names: ['Johan', 'John', 'Paul', 'Ringo']
});

assert.isString(string);
assert.match(string, new RegExp('<h2>Hi Johan', 'gm'), 'includes heading with capitalized name');
});

it('should render with a layout', () => {
const searchFor = 'Paul is dead';

const string = Mailer.render('sample', {
name: 'johan',
names: ['Johan', 'John', 'Paul', 'Ringo'],
preview: searchFor
});

assert.isString(string);
assert.match(string, new RegExp(`<title>${searchFor}</title>`, 'gm'), 'includes a <title> element from layout.html');
});
});
3 changes: 3 additions & 0 deletions example/server/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import TemplateHelpers from './lib/template-helpers';
import Templates from './lib/templates';

if (!process.env.MAIL_URL) {
process.env.MAIL_URL = Meteor.settings.MAIL_URL;
}
Expand Down
3 changes: 3 additions & 0 deletions export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Mailer as theModule } from './lib/mailer';

Mailer = theModule;
Loading