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

diffs.fixture.js « diffs « fixtures « 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: 50ea00bee00ce0839f234a1f2d5554764b5f2a09 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'use strict';

var fs = require('fs');
var cssin = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.in', 'ascii');
var cssout = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.out', 'ascii');

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

  it('should display a diff for small strings', function () {
    actual = 'foo rar baz';
    expected = 'foo bar baz';
    actual.should.equal(expected);
  });

  it('should display a diff of canonicalized objects', function () {
    actual = { name: 'travis j', age: 23 };
    expected = { age: 23, name: 'travis' };
    actual.should.equal(expected);
  });

  it('should display a diff for medium strings', function () {
    actual = 'foo bar baz\nfoo rar baz\nfoo bar raz';
    expected = 'foo bar baz\nfoo bar baz\nfoo bar baz';
    actual.should.equal(expected);
  });

  it('should display a diff for entire object dumps', function () {
    actual = {
      name: 'joel',
      age: 30,
      address: {
        city: 'new york',
        country: 'usa'
      }
    };
    expected = {
      name: 'joe',
      age: 30,
      address: {
        city: 'new york',
        country: 'us'
      }
    };
    actual.should.equal(expected);
  });

  it('should display a diff for multi-line strings', function () {
    actual = 'one two three\nfour zzzz six\nseven eight nine';
    expected = 'one two three\nfour five six\nseven eight nine';
    actual.should.equal(expected);
  });

  it('should display a diff for entire object dumps', function () {
    actual = {
      name: 'joel',
      age: 30,
      address: {
        city: 'new york',
        country: 'usa'
      }
    };
    expected = {
      name: 'joe',
      age: 30,
      address: {
        city: 'new york',
        country: 'us'
      }
    };
    actual.should.equal(expected);
  });

  it('should display a full-comparison with escaped special characters', function () {
    actual = 'one\ttab\ntwo\t\t\ttabs';
    expected = 'one\ttab\ntwo\t\ttabs';
    actual.should.equal(expected);
  });

  it('should display a word diff for large strings', function () {
    cssin.should.equal(cssout);
  });

  it('should work with objects', function () {
    actual = {
      name: 'tobi',
      species: 'ferret',
      color: 'white',
      age: 2
    };

    expected = {
      name: 'loki',
      species: 'ferret',
      color: 'brown',
      age: 2
    };

    actual.should.eql(expected);
  });

  it('should show value diffs and not be affected by commas', function () {
    actual = { a: 123 };
    expected = { a: 123, b: 456 };
    actual.should.equal(expected);
  });

  it('should display diff by data and not like an objects', function () {
    actual = new Buffer([0x01]);
    expected = new Buffer([0x02]);
    actual.should.equal(expected);
  });
});