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

diffs.spec.js « integration « test « mocha-3.1.2 « lib « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7d620e7489130a913530cc8ecf446305d17a1532 (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
'use strict';

var assert = require('assert');
var helpers = require('./helpers');
var run = helpers.runMocha;
var fs = require('fs');
var getDiffs = helpers.getDiffs;

function getExpectedOutput () {
  var output = fs.readFileSync('test/integration/fixtures/diffs/output', 'UTF8');

  // Diffs are delimited in file by "// DIFF"
  return output.split(/\s*\/\/ DIFF/).slice(1).map(function (diff) {
    return diff.split('\n').filter(Boolean).join('\n');
  });
}

describe('diffs', function () {
  var diffs, expected;

  before(function (done) {
    run('diffs/diffs.fixture.js', ['-C'], function (err, res) {
      expected = getExpectedOutput();
      diffs = getDiffs(res.output);
      done(err);
    });
  });

  [
    'should display a diff for small strings',
    'should display a diff of canonicalized objects',
    'should display a diff for medium strings',
    'should display a diff for entire object dumps',
    'should display a diff for multi-line strings',
    'should display a diff for entire object dumps',
    'should display a full-comparison with escaped special characters',
    'should display a word diff for large strings',
    'should work with objects',
    'should show value diffs and not be affected by commas',
    'should display diff by data and not like an objects'
  ].forEach(function (title, i) {
    it(title, function () {
      assert.equal(diffs[i], expected[i]);
    });
  });
});