Tests - niyogakiza/Openclassroom_Project-8 GitHub Wiki

Jasmine tests.

  • A series of unit tests with jasmine is available to you.
  • To use them open the test folder then SpecRunner.html file in the browser, I have used chrome as a browser.
  • This series of tests, makes it possible to verify the proper filter functioning of the various operations of this application like showing the tasks on the list, either the completed or active.
  • Here is the code example:
it('should highlight "Active" filter when switching to active view', function () {
		// TODO: write test
		subject.setView('#/active');
		expect(view.render).toHaveBeenCalledWith('setFilter','active');
	});

	describe('toggle all', function () {
        beforeEach(function () {
            var todos = [{id:[], title: 'my todo ', completed: false}];
            setUpModel(todos);
            subject.setView('');
            view.trigger('toggleAll', {completed: true});

        });

        it('should toggle all todos to completed', function () {
			// TODO: write test

			/*==== expect model to update the called completed id ====*/
            expect(model.update).toHaveBeenCalledWith([], {completed: true}, jasmine.any(Function));

		});

		it('should update the view', function () {
			// TODO: write test

            /*==== expect view  to render the called completed  id element. ====*/
            expect(view.render).toHaveBeenCalledWith('elementComplete', {id:[], completed: true});

		});