mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Added tests for markoc
This commit is contained in:
parent
4e9a6b108c
commit
32c820fe8f
1
test/autotests/markoc/clean-dir/template1.marko
Normal file
1
test/autotests/markoc/clean-dir/template1.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
1
test/autotests/markoc/clean-dir/template2.marko
Normal file
1
test/autotests/markoc/clean-dir/template2.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
15
test/autotests/markoc/clean-dir/test.js
Normal file
15
test/autotests/markoc/clean-dir/test.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
exports.test = function(helpers) {
|
||||||
|
|
||||||
|
helpers.spawnSync(['template1.marko']);
|
||||||
|
helpers.spawnSync(['template2.marko']);
|
||||||
|
|
||||||
|
expect(helpers.existsSync('template1.marko.js')).to.equal(true);
|
||||||
|
expect(helpers.existsSync('template2.marko.js')).to.equal(true);
|
||||||
|
|
||||||
|
helpers.spawnSync(['.', '--clean']);
|
||||||
|
|
||||||
|
expect(helpers.existsSync('template1.marko.js')).to.equal(false);
|
||||||
|
expect(helpers.existsSync('template2.marko.js')).to.equal(false);
|
||||||
|
};
|
||||||
7
test/autotests/markoc/compile-dir-no-template/test.js
Normal file
7
test/autotests/markoc/compile-dir-no-template/test.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
exports.test = function(helpers) {
|
||||||
|
var result = helpers.spawnSync(['.'], { encoding: 'utf8' });
|
||||||
|
|
||||||
|
expect(result.stdout).to.contain('No templates found');
|
||||||
|
};
|
||||||
1
test/autotests/markoc/compile-dir/template1.marko
Normal file
1
test/autotests/markoc/compile-dir/template1.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
1
test/autotests/markoc/compile-dir/template2.marko
Normal file
1
test/autotests/markoc/compile-dir/template2.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
11
test/autotests/markoc/compile-dir/test.js
Normal file
11
test/autotests/markoc/compile-dir/test.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
exports.test = function(helpers) {
|
||||||
|
expect(helpers.existsSync('template1.marko.js')).to.equal(false);
|
||||||
|
expect(helpers.existsSync('template2.marko.js')).to.equal(false);
|
||||||
|
|
||||||
|
helpers.spawnSync(['.']);
|
||||||
|
|
||||||
|
expect(helpers.existsSync('template1.marko.js')).to.equal(true);
|
||||||
|
expect(helpers.existsSync('template2.marko.js')).to.equal(true);
|
||||||
|
};
|
||||||
1
test/autotests/markoc/multiple-dirs/a/template.marko
Normal file
1
test/autotests/markoc/multiple-dirs/a/template.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
1
test/autotests/markoc/multiple-dirs/b/template.marko
Normal file
1
test/autotests/markoc/multiple-dirs/b/template.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
13
test/autotests/markoc/multiple-dirs/test.js
Normal file
13
test/autotests/markoc/multiple-dirs/test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
exports.test = function(helpers) {
|
||||||
|
expect(helpers.existsSync('a/template.marko.js')).to.equal(false);
|
||||||
|
expect(helpers.existsSync('b/template.marko.js')).to.equal(false);
|
||||||
|
expect(helpers.existsSync('excluded/template.marko.js')).to.equal(false);
|
||||||
|
|
||||||
|
helpers.spawnSync(['a', 'b']);
|
||||||
|
|
||||||
|
expect(helpers.existsSync('a/template.marko.js')).to.equal(true);
|
||||||
|
expect(helpers.existsSync('b/template.marko.js')).to.equal(true);
|
||||||
|
expect(helpers.existsSync('excluded/template.marko.js')).to.equal(false);
|
||||||
|
};
|
||||||
1
test/autotests/markoc/single-template/template.marko
Normal file
1
test/autotests/markoc/single-template/template.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
- Hello ${data.name}!
|
||||||
8
test/autotests/markoc/single-template/test.js
Normal file
8
test/autotests/markoc/single-template/test.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
exports.test = function(helpers) {
|
||||||
|
expect(helpers.existsSync('template.marko.js')).to.equal(false);
|
||||||
|
var result = helpers.spawnSync(['template.marko']);
|
||||||
|
expect(helpers.existsSync('template.marko.js')).to.equal(true);
|
||||||
|
expect(result.status).to.equal(0);
|
||||||
|
};
|
||||||
9
test/autotests/markoc/usage/test.js
Normal file
9
test/autotests/markoc/usage/test.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
exports.test = function(helpers) {
|
||||||
|
var result = helpers.spawnSync([], {
|
||||||
|
encoding: 'utf8'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.stdout).to.contain('Usage: markoc');
|
||||||
|
};
|
||||||
36
test/markoc-tests.js
Normal file
36
test/markoc-tests.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
'use strict';
|
||||||
|
require('./patch-module');
|
||||||
|
require('marko/node-require').install();
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
chai.config.includeStack = true;
|
||||||
|
|
||||||
|
var nodePath = require('path');
|
||||||
|
require('../compiler');
|
||||||
|
var autotest = require('./autotest');
|
||||||
|
var markocPath = require.resolve('../bin/markoc');
|
||||||
|
var childProcess = require('child_process');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
describe('markoc' , function() {
|
||||||
|
var autoTestDir = nodePath.join(__dirname, 'autotests/markoc');
|
||||||
|
|
||||||
|
autotest.scanDir(autoTestDir, function run(dir, helpers, done) {
|
||||||
|
var testModule = require(nodePath.join(dir, 'test.js'));
|
||||||
|
helpers.existsSync = function(filename) {
|
||||||
|
return fs.existsSync(nodePath.join(dir, filename));
|
||||||
|
};
|
||||||
|
helpers.spawnSync = function(args, options) {
|
||||||
|
options = options || {};
|
||||||
|
if (!options.cwd) {
|
||||||
|
options.cwd = dir;
|
||||||
|
}
|
||||||
|
return childProcess.spawnSync(markocPath, args, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
helpers.spawnSync(['.', '--clean']);
|
||||||
|
|
||||||
|
testModule.test(helpers);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user