{"size": 2401, "ext": "js", "max_stars_repo_path": "spec/notes.spec.js", "max_stars_repo_name": "HenrikAho/WEB-Sovelluskehitys", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "spec/notes.spec.js", "max_issues_repo_name": "HenrikAho/WEB-Sovelluskehitys", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "spec/notes.spec.js", "max_forks_repo_name": "HenrikAho/WEB-Sovelluskehitys", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.3472222222, "max_line_length": 81, "alphanum_fraction": 0.5214493961}
describe('notes module', function () {
    beforeEach(function() {
        notes.clear();
        notes.add('first note');
        notes.add('second note');
        notes.add('third note');
        notes.add('fourth note');
        notes.add('fifth note');
    });
    describe('adding a note', function() {

        it("should be able to add a new note", function () {
            expect(notes.add('sixth note')).toBe(true);
            expect(notes.count()).toBe(6);
        });

        it("should ignore blank notes", function () {
            expect(notes.add('')).toBe(false);
            expect(notes.count()).toBe(5);
        });

        it('should ignore notes containing only whitespace', function() {
            expect(notes.add('   ')).toBe(false);
            expect(notes.count()).toBe(5);
        });

        it('should require a string parameter', function() {
            expect(notes.add()).toBe(false);
            expect(notes.count()).toBe(5);
        });
    });

    describe('deleting a note', function() {

        it('should be able to delete the first index', function () {
            expect(notes.remove('"' + notes[0] + '"')).toBe(true);
            expect(notes.count()).toBe(4);
        });

        it('should be able to delete the last index', function () {
            expect(notes.remove('"' + notes[notes.length] - 1 + '"')).toBe(true);
            expect(notes.count()).toBe(4);
        });

        it('should return false if index is out of range', function() {
            expect(notes.remove(notes.length)).toBe(false);
            expect(notes.count()).toBe(5);
        });

        it('should return false if the parameter is missing', function() {
            expect(notes.remove()).toBe(false);
            expect(notes.count()).toBe(5);
        });
    });

    describe('finding a note', function () {
        it('should be able to find the first index', function () {
            expect(notes.find('first note')).toBe(true);
            expect(notes.count()).toBe(5);
        });
        it('should be able to find the last index', function () {
            expect(notes.find('fifth note')).toBe(true);
            expect(notes.count()).toBe(5);
        });
        it('should return false if the parameter is missing', function () {
            expect(notes.remove()).toBe(false);
            expect(notes.count()).toBe(5);
        });
    })
});

