| 1 | describe("Others common methods (admin/js/common.js)", function() { | 
|---|
| 2 |      describe("postsActionsHelper", function() { | 
|---|
| 3 |           it("A confirm popup must appear if action is \"delete\" and at least on checkbox is checked", function() { | 
|---|
| 4 |                loadFixtures('posts_list.html'); | 
|---|
| 5 |                dotclear.postsActionsHelper(); | 
|---|
| 6 |                 | 
|---|
| 7 |                spyOn(window, 'confirm').andReturn(false); | 
|---|
| 8 |                var submitCallback = jasmine.createSpy().andReturn(false); | 
|---|
| 9 |                $('#form-entries').submit(submitCallback); | 
|---|
| 10 |  | 
|---|
| 11 |                $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); | 
|---|
| 12 |                $('input[type="checkbox"][name="entries[]"][value="2"]').attr('checked', 'checked'); | 
|---|
| 13 |  | 
|---|
| 14 |                $('#form-entries').trigger('submit'); | 
|---|
| 15 |                expect(window.confirm).toHaveBeenCalled(); | 
|---|
| 16 |           }); | 
|---|
| 17 |           it("Confirm popup doesn't appear if action is \"delete\" but no checkbox is checked", function() { | 
|---|
| 18 |                loadFixtures('posts_list.html'); | 
|---|
| 19 |                dotclear.postsActionsHelper(); | 
|---|
| 20 |                 | 
|---|
| 21 |                spyOn(window, 'confirm').andReturn(false); | 
|---|
| 22 |                var submitCallback = jasmine.createSpy().andReturn(false); | 
|---|
| 23 |                $('#form-entries').submit(submitCallback); | 
|---|
| 24 |  | 
|---|
| 25 |                $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); | 
|---|
| 26 |                $('#form-entries').trigger('submit'); | 
|---|
| 27 |                expect(window.confirm).not.toHaveBeenCalled(); | 
|---|
| 28 |           }); | 
|---|
| 29 |           it("Others actions don't show confirm popup", function() { | 
|---|
| 30 |                loadFixtures('posts_list.html'); | 
|---|
| 31 |                dotclear.postsActionsHelper(); | 
|---|
| 32 |                 | 
|---|
| 33 |                spyOn(window, 'confirm').andReturn(false); | 
|---|
| 34 |                var submitCallback = jasmine.createSpy().andReturn(false); | 
|---|
| 35 |                $('#form-entries').submit(submitCallback); | 
|---|
| 36 |  | 
|---|
| 37 |                $('select[name="action"] option[value="publish"]').attr('selected', 'selected'); | 
|---|
| 38 |                $('#form-entries').trigger('submit'); | 
|---|
| 39 |                expect(window.confirm).not.toHaveBeenCalled(); | 
|---|
| 40 |           }); | 
|---|
| 41 |      }); | 
|---|
| 42 |  | 
|---|
| 43 |      describe("commentsActionsHelper", function() { | 
|---|
| 44 |           it("A confirm popup must appear if action is \"delete\" and at least on checkbox is checked", function() { | 
|---|
| 45 |                loadFixtures('comments_list.html'); | 
|---|
| 46 |                dotclear.commentsActionsHelper(); | 
|---|
| 47 |                 | 
|---|
| 48 |                spyOn(window, 'confirm').andReturn(false); | 
|---|
| 49 |                var submitCallback = jasmine.createSpy().andReturn(false); | 
|---|
| 50 |                $('#form-comments').submit(submitCallback); | 
|---|
| 51 |  | 
|---|
| 52 |                $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); | 
|---|
| 53 |                $('input[type="checkbox"][name="comments[]"][value="2"]').attr('checked', 'checked'); | 
|---|
| 54 |  | 
|---|
| 55 |                $('#form-comments').trigger('submit'); | 
|---|
| 56 |                expect(window.confirm).toHaveBeenCalled(); | 
|---|
| 57 |           }); | 
|---|
| 58 |           it("Confirm popup doesn't appear if action is \"delete\" but no checkbox is checked", function() { | 
|---|
| 59 |                loadFixtures('comments_list.html'); | 
|---|
| 60 |                dotclear.commentsActionsHelper(); | 
|---|
| 61 |                 | 
|---|
| 62 |                spyOn(window, 'confirm').andReturn(false); | 
|---|
| 63 |                var submitCallback = jasmine.createSpy().andReturn(false); | 
|---|
| 64 |                $('#form-comments').submit(submitCallback); | 
|---|
| 65 |  | 
|---|
| 66 |                $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); | 
|---|
| 67 |                $('#form-comments').trigger('submit'); | 
|---|
| 68 |                expect(window.confirm).not.toHaveBeenCalled(); | 
|---|
| 69 |           }); | 
|---|
| 70 |           it("Others actions don't show confirm popup", function() { | 
|---|
| 71 |                loadFixtures('comments_list.html'); | 
|---|
| 72 |                dotclear.commentsActionsHelper(); | 
|---|
| 73 |                 | 
|---|
| 74 |                spyOn(window, 'confirm').andReturn(false); | 
|---|
| 75 |                var submitCallback = jasmine.createSpy().andReturn(false); | 
|---|
| 76 |                $('#form-comments').submit(submitCallback); | 
|---|
| 77 |  | 
|---|
| 78 |                $('select[name="action"] option[value="publish"]').attr('selected', 'selected'); | 
|---|
| 79 |                $('#form-comments').trigger('submit'); | 
|---|
| 80 |                expect(window.confirm).not.toHaveBeenCalled(); | 
|---|
| 81 |           }); | 
|---|
| 82 |      }); | 
|---|
| 83 | }); | 
|---|