<commit_before>import {fdescribe,describe,expect,fit,it,xit, inject,beforeEach, beforeEachProviders} from 'angular2/testing';
import {provide} from "angular2/core";
import {IndexeddbDatastore} from "../app/datastore/indexeddb-datastore";
import {DB} from "../app/datastore/db";
import {Indexeddb} from "../app/datastore/indexeddb";

/**
 * @author <NAME>
 */
export function main() {
    describe('IndexeddbDatastore', () => {

        var datastore : IndexeddbDatastore;
        var request;
        var request2;
        var i;

        var object = {
            "identifier": "ob1",
            "title": "Title",
            "type": "Object",
            "synced": 0,
            "valid": true,
        };

        beforeEach(
            function () {
                var indexeddb   = jasmine.createSpyObj('indexeddb', [ 'put' ]);
                request   = jasmine.createSpyObj('request', [ 'a' ]);
                request2   = jasmine.createSpyObj('request', [ 'a' ]);

                i=0;
                indexeddb.put.and.callFake(function(){if (i==0) {
                    i++; return request;} else return request2; });

                datastore = new IndexeddbDatastore(
                    <Indexeddb> { db: function(){return { then: function (db) { db(indexeddb); }}}});
            }
        );

        it('should do basic stuff',
            function (done) {

                var p= datastore.create(object);

                request.onerror("reqerror");
                request2.onerror("req2error");

                p.then(
                    () => {},
                    err => {
                        expect(object["id"]).toBe(undefined);done()
                    }
                );
            }
        );
    })
}<commit_msg>Prevent false positive.<commit_after>import {fdescribe,describe,expect,fit,it,xit, inject,beforeEach, beforeEachProviders} from 'angular2/testing';
import {provide} from "angular2/core";
import {IndexeddbDatastore} from "../app/datastore/indexeddb-datastore";
import {Indexeddb} from "../app/datastore/indexeddb";

/**
 * @author <NAME>
 */
export function main() {
    describe('IndexeddbDatastore', () => {

        var datastore : IndexeddbDatastore;
        var request;
        var request2;
        var i;

        var object = {
            "identifier": "ob1",
            "title": "Title",
            "type": "Object",
            "synced": 0,
            "valid": true,
        };

        beforeEach(
            function () {
                var indexeddb   = jasmine.createSpyObj('indexeddb', [ 'put' ]);
                request   = jasmine.createSpyObj('request', [ 'a' ]);
                request2   = jasmine.createSpyObj('request', [ 'a' ]);

                i=0;
                indexeddb.put.and.callFake(function(){if (i==0) {
                    i++; return request;} else return request2; });

                datastore = new IndexeddbDatastore(
                    <Indexeddb> { db: function(){return { then: function (db) { db(indexeddb); }}}});
            }
        );

        it('should revert id on failed creation',
            function (done) {

                var p= datastore.create(object);

                request.onerror("reqerror");
                request2.onerror("req2error");

                p.then(
                    () => {
                        fail(); done();
                    },
                    err => {
                        expect(object["id"]).toBe(undefined); done()
                    }
                );
            }
        );
    })
}
{'fraction_non_alphanumeric': 0.14257703081232492, 'fraction_numerical': 0.0061624649859943975, 'mean_word_length': 1.5380241648898365, 'pattern_counts': {'":': 10, '<': 7, '<?xml version=': 0, '>': 13, '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': '4537513', 'n_tokens_mistral': 1053, 'n_tokens_neox': 980, 'n_words': 191}