summaryrefslogtreecommitdiffstats
path: root/lib/modifiers/summary/__tests__/editPartTitle.js
blob: d1b916b5ee3675040c6cfb656073e92ebc02a876 (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
var Summary = require('../../../models/summary');
var File = require('../../../models/file');

describe('editPartTitle', function() {
    var editPartTitle = require('../editPartTitle');
    var summary = Summary.createFromParts(File(), [
        {
            articles: [
                {
                    title: 'My First Article',
                    path: 'README.md'
                },
                {
                    title: 'My Second Article',
                    path: 'article.md'
                }
            ]
        },
        {
            title: 'Test'
        }
    ]);

    it('should correctly set title of first part', function() {
        var newSummary = editPartTitle(summary, 0, 'Hello World');
        var part = newSummary.getPart(0);

        expect(part.getTitle()).toBe('Hello World');
    });

    it('should correctly set title of second part', function() {
        var newSummary = editPartTitle(summary, 1, 'Hello');
        var part = newSummary.getPart(1);

        expect(part.getTitle()).toBe('Hello');
    });

    it('should not fail if part doesn\'t exist', function() {
        var newSummary = editPartTitle(summary, 3, 'Hello');
        expect(newSummary.getParts().size).toBe(2);
    });
});