1 | 'use strict';
|
2 |
|
3 | var exec = require('child_process').exec;
|
4 | var fs = require('fs');
|
5 | var path = require('path');
|
6 | var assert = require('chai').assert;
|
7 | var examples = fs.readdirSync(path.join(__dirname, '../examples/')).filter(function (file) {
|
8 | return file !== 'oauth.js';
|
9 | });
|
10 |
|
11 | function runExample(name, cb) {
|
12 | return exec('node ' + path.join(__dirname, '../examples/', name), cb);
|
13 | }
|
14 |
|
15 | examples.forEach(function (name) {
|
16 | describe(name, function () {
|
17 | it('does not error', function (done) {
|
18 | this.timeout(10000);
|
19 | runExample(name, function assertOutput(err, stdout, stderr) {
|
20 | assert(!err, 'Expected example not to error');
|
21 | assert.notEqual(stdout, '', 'Expected some output');
|
22 | assert.notMatch(stdout, /error/gi,
|
23 | 'Expected no error in output');
|
24 | assert.notMatch(stderr, /error/gi,
|
25 | 'Expected no error in output');
|
26 | done();
|
27 | });
|
28 | });
|
29 | });
|
30 | });
|