<commit_before>/**
 * Copyright (c) 2013, <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING file.
 */


describe('SaveQueue', function() {

	var http,
		q;

	beforeEach(module('Notes'));

	beforeEach(inject(function ($httpBackend, $q) {
		http = $httpBackend;
		q = $q;
	}));

	it ('should sync a note', inject(function(SaveQueue) {
		/*var note = {
			id: 3,
			put: function () {
				return q.defer().promise;
			}
		};
		SaveQueue.add(note);
		expect().toBe();*/
	}));


	it ('should sync a note synchronously', inject(function(SaveQueue) {

	}));


	it ('should sync updated notes', inject(function(SaveQueue) {

	}));


	afterEach(function() {
		http.verifyNoOutstandingExpectation();
		http.verifyNoOutstandingRequest();
	});<commit_msg>added unit test for save queue<commit_after>/**
 * Copyright (c) 2013, <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING file.
 */


describe('SaveQueue', function() {

	var http,
		q,
		rootScope;

	beforeEach(module('Notes'));

	beforeEach(inject(function ($httpBackend, $q, $rootScope) {
		http = $httpBackend;
		q = $q;
		rootScope = $rootScope;
	}));

	it ('should sync a note', inject(function(SaveQueue) {
		var request = q.defer();
		var note = {
			id: 3,
			put: function () {
				return request.promise;
			}
		};
		SaveQueue.add(note);

		request.resolve({
			title: 'yo',
			modified: 4
		});

		// $q needs a digest on $rootScope
		rootScope.$apply();

		expect(note.title).toBe('yo');
		expect(note.modified).toBe(4);
	}));


	it ('should sync more notes', inject(function(SaveQueue) {
		// note 1
		var requestNote1 = q.defer();
		var note1 = {
			id: 3,
			put: function () {
				return requestNote1.promise;
			}
		};
		SaveQueue.add(note1);

		// note 2
		var requestNote2 = q.defer();
		var note2 = {
			id: 4,
			put: function () {
				return requestNote2.promise;
			}
		};
		SaveQueue.add(note2);

		requestNote1.resolve({
			title: 'note1',
			modified: 6
		});

		requestNote2.resolve({
			title: 'note2',
			modified: 7
		});

		// $q needs a digest on $rootScope
		rootScope.$apply();

		expect(note1.title).toBe('note1');
		expect(note1.modified).toBe(6);

		expect(note2.title).toBe('note2');
		expect(note2.modified).toBe(7);
	}));


	afterEach(function() {
		http.verifyNoOutstandingExpectation();
		http.verifyNoOutstandingRequest();
	});
{'fraction_non_alphanumeric': 0.16578411405295315, 'fraction_numerical': 0.016293279022403257, 'mean_word_length': 3.4817518248175183, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6331431', 'n_tokens_mistral': 985, 'n_tokens_neox': 840, 'n_words': 205}