all files / spec/ pluginSpec.js

100% Statements 18/18
100% Branches 0/0
100% Functions 6/6
100% Lines 18/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63                                                                                         
/**
 * pluginSpec.js
 * Copyright (C) 2017 eleal 
 *
 * Distributed under terms of the MIT license.
 */
var requirejs = require("requirejs");
 
requirejs.config({
    baseUrl: __dirname + "/../src/",
    nodeRequire: require
});
var plugin = requirejs("plugin");
 
var componentScript = 
'(function(template){\n' +
'    define("vue!component", ["Vue"], function(Vue) {\n' +
'		Vue.component("my-component", {\n' +
'			template: template,\n' +
'			data: function() {\n' +
'				return {"text": "Ok"};\n' +
'			}\n' +
'		});\n' +
'    });\n' +
'})(\'	<div>{{text}}</div>\');';
 
 
describe("Script with attributes", function() {
 
    it("Setup", function() {
        expect(plugin).not.toBe(null);
        expect(plugin.load).not.toBe(null);
    });
 
    it("Callback", function() {
        var donefn = jasmine.createSpy("success");
 
        var onload = {
            // fromText: donefn
            fromText: function(text) {
                donefn(text);
            }
        };
 
        var req = function(dep, callback) {
 
            callback();
        };
 
        req.toUrl = function(text) {
            return "examples/" + text;
        };
 
        plugin.load("component", req, onload, {isBuild: true});
 
 
        expect(donefn).toHaveBeenCalledWith(componentScript);
    });
 
});
 
/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab : */