var kanso = require('../lib/kanso'),
    dust = require('../deps/dustjs/lib/dust'),
    settings = require('../lib/settings'),
    fs = require('fs');


// integration test
exports['load'] = function (test) {
    var pdir = __dirname + '/fixtures/testproject';
    settings.load(pdir, function (err, settings) {
        test.ifError(err);
        kanso.load(pdir, settings, function (err, doc) {
            test.ifError(err);
            test.same(doc.settings, {
                'name': 'testproject',
                'load': 'lib/app',
                'modules': ['deps','lib'],
                'templates': 'templates',
                'attachments': 'static'
            });
            test.equals(doc.testproperty, 'test property');
            test.same(Object.keys(doc.lib).sort(), ['module1','app'].sort());
            test.equals(
                doc.lib.module1,
                fs.readFileSync(pdir + '/lib/module1.js').toString()
            );
            test.equals(
                doc.lib.app,
                fs.readFileSync(pdir + '/lib/app.js').toString()
            );
            test.same(doc.shows, {
                'testshow': 'function(){' +
                    'return require("lib/app")["shows"]["testshow"]' +
                        '.apply(this, arguments);' +
                '}'
            });
            test.same(doc.lists, {
                'testlist': 'function(){' +
                    'return require("lib/app")["lists"]["testlist"]' +
                        '.apply(this, arguments);' +
                '}'
            });
            test.same(doc.updates, {
                'testupdate': 'function(){' +
                    'return require("lib/app")["updates"]["testupdate"]' +
                        '.apply(this, arguments);' +
                '}'
            });
            test.same(doc.filters, {
                'testfilter': 'function(){' +
                    'return require("lib/app")["filters"]["testfilter"]' +
                        '.apply(this, arguments);' +
                '}'
            });
            test.equals(
                doc.validate_doc_update,
                'function(){' +
                    'return require("lib/app")["validate_doc_update"]' +
                        '.apply(this, arguments);' +
                '}'
            );
            test.same(doc.deps, {
                'module2': 'exports.name = "module two";\n'
            });
            test.equal(
                doc.templates,
                fs.readFileSync(
                    __dirname + '/../deps/dustjs/lib/dust.js'
                ).toString() +
                dust.compile('<h1>Test</h1>\n', 'test.html') +
                dust.compile(fs.readFileSync(
                    __dirname + '/../templates/kanso'
                ).toString(), 'kanso')
            );
            test.equal(
                doc.no_proxy_function,
                'function (){return "test";}'
            );
            test.same(doc.no_proxy_obj, {
                fn1: 'function (){return "one";}',
                fn2: 'function (){return "two";}'
            });
            test.same(doc._attachments, {
                'static/test.txt': {
                    'content-type': 'text/plain',
                    'data': 'dGVzdCBkYXRhCg=='
                }
            });
            test.done();
        });
    });
};

@@ -2701,16 +2701,97 @@
 compile(
+%0A                    '%3Cscript type=%22text/javascript%22%3E' +%0A                        
 fs.readF
@@ -2811,32 +2811,40 @@
                 
+   
+     
 __dirname + '/..
@@ -2858,15 +2858,30 @@
 tes/
-kanso'%0A
+bootstrap.js'%0A        
     
@@ -2908,17 +2908,130 @@
 ng()
-, 'kanso'
+ +%0A                        'kanso.init();' +%0A                    '%3C/script%3E',%0A                    'kanso'%0A                
 )%0A  

fix kanso load test