note_spec.js 1.61 KB
Newer Older
1 2 3 4 5 6 7
define([
    'js/spec/edxnotes/helpers', 'js/edxnotes/collections/notes'
], function(Helpers, NotesCollection) {
    'use strict';
    describe('EdxNotes NoteModel', function() {
        beforeEach(function () {
            this.collection = new NotesCollection([
8 9
                {quote: Helpers.LONG_TEXT, text: 'text\n with\r\nline\n\rbreaks \r'},
                {quote: Helpers.SHORT_TEXT, text: 'text\n with\r\nline\n\rbreaks \r'}
10 11 12 13 14 15 16 17 18 19
            ]);
        });

        it('has correct values on initialization', function () {
            expect(this.collection.at(0).get('is_expanded')).toBeFalsy();
            expect(this.collection.at(0).get('show_link')).toBeTruthy();
            expect(this.collection.at(1).get('is_expanded')).toBeFalsy();
            expect(this.collection.at(1).get('show_link')).toBeFalsy();
        });

20
        it('can return appropriate `quote`', function () {
21 22 23
            var model = this.collection.at(0);

            // is_expanded = false, show_link = true
24
            expect(model.getQuote()).toBe(Helpers.PRUNED_TEXT);
25 26
            model.set('is_expanded', true);
            // is_expanded = true, show_link = true
27
            expect(model.getQuote()).toBe(Helpers.LONG_TEXT);
28 29 30
            model.set('show_link', false);
            model.set('is_expanded', false);
            // is_expanded = false, show_link = false
31 32 33 34 35 36
            expect(model.getQuote()).toBe(Helpers.LONG_TEXT);
        });

        it('can return appropriate `text`', function () {
            var model = this.collection.at(0);
            expect(model.getText()).toBe('text<br> with<br>line<br>breaks <br>');
37 38 39
        });
    });
});