summaryrefslogtreecommitdiff
path: root/support/build.test.js
blob: cc56348343f1fe61725b4f9e3366479819a2b1df (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Smoke test for the CJS build
var methods = ["each", "waterfall", "queue", "eachSeries"];
var expect = require('chai').expect;
var rollup = require('rollup').rollup;
var rollupPluginNodeResolve = require('rollup-plugin-node-resolve');
var fs = require('fs');
var exec = require('child_process').exec;

describe("async main", function() {
    var async;

    before(function() {
        async = require("../build/");
    });

    it("should have methods", function() {
        methods.forEach(function(methodName) {
            expect(async[methodName]).to.be.a("function");
        });
    });
});

describe("async umd", function() {
    var async;

    before(function() {
        async = require("../build/dist/async.js");
    });

    it("should have methods", function() {
        methods.forEach(function(methodName) {
            expect(async[methodName]).to.be.a("function");
        });
    });
});

describe("async umd minified", function() {
    var async;

    before(function() {
        async = require("../build/dist/async.min.js");
    });

    it("should have methods", function() {
        methods.forEach(function(methodName) {
            expect(async[methodName]).to.be.a("function");
        });
    });
});

methods.forEach(function (methodName) {
    describe("async." + methodName, function () {
        var method;
        before(function () {
            method = require("../build/" + methodName);
        });

        it("should require the individual method", function() {
            expect(method).to.be.a("function");
        });
    });
});

describe("ES Modules", function () {
    var tmpDir = __dirname + "/../tmp";
    var buildFile = __dirname + "/../tmp/es.test.js";

    before(function (done) {
        if (fs.existsSync(tmpDir)) {
            return done();
        }
        fs.mkdir(tmpDir, done);
    });

    before(function () {
        return rollup({
            entry: __dirname + "/es.test.js",
            plugins: [
                rollupPluginNodeResolve()
            ]
        }).then(function (bundle) {
            return bundle.write({
                format: "umd",
                dest: buildFile
            });
        });
    });

    it("should build a successful bundle", function (done) {
        exec("node " + buildFile, function (err, stdout) {
            if (err) { return done(err); }
            expect(stdout).to.match(/42/);
            done();
        });
    });
});