<commit_before>/*
 * Copyright (c) 2013, Yahoo! Inc.  All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

/*jslint anon:true, sloppy:true, nomen:true, stupid:true, plusplus:true */
/*globals YUI*/

YUI().use('mojito-test-extra', 'test', 'json-parse', 'json-stringify', function(Y) {

    var suite = new Y.Test.Suite('test compile'),
        A = Y.Assert,
        AA = Y.ArrayAssert,
        OA = Y.ObjectAssert,

        libpath = require('path'),
        cmdpath = libpath.join(__dirname, '../../../../../lib/app/commands/compile.js');


    suite.add(new Y.Test.Case({

        name: 'test compile cases basic',


        'test require': function() {
            var compilecmd = require(cmdpath);
            A.isObject(compilecmd);
            A.isFunction(compilecmd.run, 'No run function exported');
            A.isString(compilecmd.usage, 'No usage string exported');
            A.isArray(compilecmd.options, 'No options array exported');
        },


        'test getInlineCssMojits': function() {
            var compilecmd = require(cmdpath);
            var fixtures = libpath.join(__dirname, '../../../../fixtures/store');
            var context = {};
            var store = {
                _mkRes: function(type, subtype, name, mojit, path) {
                    return {
                        type: type,
                        subtype: subtype,
                        name: name,
                        mojit: mojit,
                        source: {
                            fs: {
                                fullPath: libpath.join(fixtures, path)
                            },
                            pkg: {
                                name: 'store'
                            }
                        },
                        url: '/static/' + [type, subtype, name].join('-')
                    };
                },
                listAllMojits: function() {
                    return ['orange', 'red'];
                },
                getResources: function(env, ctx, filter) {
                    if ('mojit' === filter.type) {
                        return [
                            this._mkRes('mojit', null, filter.mojit, null, 'mojits/' + filter.mojit)
                        ];
                    }
                    return [
                        this._mkRes('asset', 'css', 'foo', filter.mojit, 'mojits/' + filter.mojit + '/assets/foo.css'),
                        this._mkRes('asset', 'css', 'bar', filter.mojit, 'mojits/' + filter.mojit + '/assets/bar.css')
                    ];
                },
                selector: {
                    getPOSLFromContext: function(ctx) {
                        return [ 's2', 's1', '*' ];
                    }
                }
            };

            A.isObject(compilecmd);
            A.isFunction(compilecmd.test.getInlineCssMojits);
            var have = compilecmd.test.getInlineCssMojits(store, 'client', context);
            var want = [
                {
                    mojitName: 'orange',
                    yuiModuleName: 'inlinecss/orange',
                    dest: '/Users/folta/work/yahoo/mojito/gh-drewfish/tests/fixtures/store/mojits/undefined/autoload/compiled/inlinecss.s2.common.js',
                    srcs: {
                        '/static/asset-css-foo': true,
                        '/static/asset-css-bar': true
                    }
                },
                {
                    mojitName: 'red',
                    yuiModuleName: 'inlinecss/red',
                    dest: '/Users/folta/work/yahoo/mojito/gh-drewfish/tests/fixtures/store/mojits/undefined/autoload/compiled/inlinecss.s2.common.js',
                    srcs: {
                        '/static/asset-css-foo': true,
                        '/static/asset-css-bar': true
                    }
                }
            ];
            Y.TEST_CMP(want, have);
        }


    }));


    Y.Test.Runner.add(suite);
});<commit_msg>fixing commands/compile unit test<commit_after>/*
 * Copyright (c) 2013, Yahoo! Inc.  All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

/*jslint anon:true, sloppy:true, nomen:true, stupid:true, plusplus:true */
/*globals YUI*/

YUI().use('mojito-test-extra', 'test', 'json-parse', 'json-stringify', function(Y) {

    var suite = new Y.Test.Suite('test compile'),
        A = Y.Assert,
        AA = Y.ArrayAssert,
        OA = Y.ObjectAssert,

        libpath = require('path'),
        cmdpath = libpath.join(__dirname, '../../../../../lib/app/commands/compile.js');


    suite.add(new Y.Test.Case({

        name: 'test compile cases basic',


        'test require': function() {
            var compilecmd = require(cmdpath);
            A.isObject(compilecmd);
            A.isFunction(compilecmd.run, 'No run function exported');
            A.isString(compilecmd.usage, 'No usage string exported');
            A.isArray(compilecmd.options, 'No options array exported');
        },


        'test getInlineCssMojits': function() {
            var compilecmd = require(cmdpath);
            var fixtures = libpath.join(__dirname, '../../../../fixtures/store');
            var context = {};
            var store = {
                _mkRes: function(type, subtype, name, mojit, path) {
                    return {
                        type: type,
                        subtype: subtype,
                        name: name,
                        mojit: mojit,
                        source: {
                            fs: {
                                fullPath: libpath.join(fixtures, path)
                            },
                            pkg: {
                                name: 'store'
                            }
                        },
                        url: '/static/' + [type, subtype, name].join('-')
                    };
                },
                listAllMojits: function() {
                    return ['orange', 'red'];
                },
                getResources: function(env, ctx, filter) {
                    if ('mojit' === filter.type) {
                        return [
                            this._mkRes('mojit', null, filter.mojit, null, 'mojits/' + filter.name)
                        ];
                    }
                    return [
                        this._mkRes('asset', 'css', 'foo', filter.mojit, 'mojits/' + filter.mojit + '/assets/foo.css'),
                        this._mkRes('asset', 'css', 'bar', filter.mojit, 'mojits/' + filter.mojit + '/assets/bar.css')
                    ];
                },
                selector: {
                    getPOSLFromContext: function(ctx) {
                        return [ 's2', 's1', '*' ];
                    }
                }
            };

            A.isObject(compilecmd);
            A.isFunction(compilecmd.test.getInlineCssMojits);
            var have = compilecmd.test.getInlineCssMojits(store, 'client', context);
            var want = [
                {
                    mojitName: 'orange',
                    yuiModuleName: 'inlinecss/orange',
                    dest: fixtures + '/mojits/orange/autoload/compiled/inlinecss.s2.common.js',
                    srcs: {
                        '/static/asset-css-foo': true,
                        '/static/asset-css-bar': true
                    }
                },
                {
                    mojitName: 'red',
                    yuiModuleName: 'inlinecss/red',
                    dest: fixtures + '/mojits/red/autoload/compiled/inlinecss.s2.common.js',
                    srcs: {
                        '/static/asset-css-foo': true,
                        '/static/asset-css-bar': true
                    }
                }
            ];
            Y.TEST_CMP(want, have);
        }


    }));


    Y.Test.Runner.add(suite);
});
{'fraction_non_alphanumeric': 0.1284965034965035, 'fraction_numerical': 0.001998001998001998, 'mean_word_length': 1.1260950358375366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3215352', 'n_tokens_mistral': 2224, 'n_tokens_neox': 2062, 'n_words': 399}