UNPKG

2.84 kBJavaScriptView Raw
1var assert = require('assert');
2var fs = require('fs');
3var path = require('path');
4var prjDir = path.join(__dirname, 'compile');
5var compile = require('../lib/compile.js');
6var debug = require('debug')('compile test');
7var modDir = path.join(prjDir, 'mods');
8
9var op = {
10 cdnPath : 'http://a.tbcdn.cn/apps'
11};
12
13describe('编译为线上格式', function(){
14// describe('当前目录引用', function(){
15// it('简单模块SSI内容', function(){
16// var page = path.join(prjDir,'pages','direct.html');
17// debug('Html文件路径:',page);
18// var v = compile.ssi(page, '/direct.html',[],op);
19// var exp = fs.readFileSync(path.join(prjDir, 'expect', 'direct.html'));
20// assert.equal(exp, v);
21// });
22// it('模块嵌套模块', function(){
23// var page = path.join(prjDir,'pages','nest.html');
24// debug('Html文件路径:',page);
25// var v = compile.ssi(page, '/nest.html',[modDir],op);
26// var exp = fs.readFileSync(path.join(prjDir, 'expect', 'nest.html'));
27// assert.equal(exp, v);
28// });
29//
30// });
31//
32// describe('模块库', function(){
33// it('简单引用', function(){
34// var page = path.join(prjDir,'pages','lib.html');
35//
36// debug('Html文件路径:',page);
37// var v = compile.ssi(page, '/lib.html',[modDir],op);
38// debug('Html文件内容:', v);
39// var exp = fs.readFileSync(path.join(prjDir, 'expect', 'lib.html'));
40// assert.equal(exp, v);
41// });
42//
43// it('嵌套引用模块库中的模块', function(){
44// var page = path.join(prjDir,'pages','libnest.html');
45// debug('Html文件路径:',page);
46// var v = compile.ssi(page, '/libnest.html',[modDir],op);
47// var exp = fs.readFileSync(path.join(prjDir, 'expect', 'libnest.html'));
48// assert.equal(exp, v);
49// });
50// it('模块库中的模块按照当前目录引用本地模块', function(){
51// var page = path.join(prjDir,'pages','liblocal.html');
52// debug('Html文件路径:',page);
53// var v = compile.ssi(page, '/aaa/bbb/ccc/liblocal.html',[modDir],op);
54// var exp = fs.readFileSync(path.join(prjDir, 'expect', 'liblocal.html'));
55// assert.equal(exp, v);
56// });
57// });
58
59 describe('抽出资源', function(){
60 it('抽出脚本', function(){
61 var page = path.join(prjDir,'pages','direct.html');
62 debug('Html文件路径:',page);
63 var v = compile.render(page, '/direct.html',[],op);
64 debug('render后内容:%s', v);
65 //var exp = fs.readFileSync(path.join(prjDir, 'expect', 'direct_rendered.html'));
66 //assert.equal(exp, v);
67 });
68 });
69})