Welcome to mirror list, hosted at ThFree Co, Russian Federation.

hooks.spec.js « integration « test « mocha-3.1.0 « lib « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7633cb5630f31fbcbc22f846b31ef9d0cb016afc (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
var assert = require('assert');
var run    = require('./helpers').runMocha;
var splitRegExp = require('./helpers').splitRegExp;
var args   = [];

describe('hooks', function() {
  it('are ran in correct order', function(done) {
    run('cascade.fixture.js', args, function(err, res) {
      var lines, expected;

      assert(!err);

      lines = res.output.split(splitRegExp).map(function(line) {
        return line.trim();
      }).filter(function(line) {
        return line.length;
      }).slice(0, -1);

      expected = [
        'before one',
        'before two',
        'before three',
        'before each one',
        'before each two',
        'before each three',
        'TEST three',
        'after each three',
        'after each two',
        'after each one',
        'after three',
        'after two',
        'after one'
      ];

      expected.forEach(function(line, i) {
        assert.equal(lines[i], line);
      });

      assert.equal(res.code, 0);
      done();
    });
  });
});