jsinput_spec.js 909 Bytes
Newer Older
1
describe('JSInput', function() {
2 3
    var $jsinputContainers;
    var $inputFields;
stv committed
4

5
    beforeEach(function() {
6
        loadFixtures('js/capa/fixtures/jsinput.html');
7 8
        $jsinputContainers = $('.jsinput');
        $inputFields = $('input[id^="input_"]');
stv committed
9
        JSInput.walkDOM();
10 11
    });

12
    it('sets all data-processed attributes to true on first load', function() {
13
        $jsinputContainers.each(function(index, item) {
stv committed
14
            expect(item).toHaveData('processed', true);
15 16 17
        });
    });

18
    it('sets the waitfor attribute to its update function', function() {
19
        $inputFields.each(function(index, item) {
stv committed
20
            expect(item).toHaveAttr('waitfor');
21
        });
22
    });
stv committed
23

24 25 26
    it('tests the correct number of jsinput instances', function() {
        expect($jsinputContainers.length).toEqual(2);
        expect($jsinputContainers.length).toEqual($inputFields.length);
stv committed
27
    });
28
});
stv committed
29