Code coverage report for spec/generic/typed.spec.js

Statements: 92.86% (13 / 14)      Branches: 75% (3 / 4)      Functions: 75% (3 / 4)      Lines: 92.31% (12 / 13)      Ignored: none     

All files » spec/generic/ » typed.spec.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 741   1 1 1 1   1 2 2         1                                                                                               1           1   1      
Eif (typeof(window) === 'undefined') var loki = require('../../src/lokijs.js');
  
describe('typed', function () {
  it('works', function () {
    var db = new loki('test.json');
    var users;
 
    function User(n) {
      this.name = n || '';
      this.log = function () {
        console.log('Name: ' + this.name);
      };
    }
 
    var json = {
      "filename": "test.json",
      "collections": [{
        "name": "users",
        "data": [{
          "name": "joe",
          "objType": "users",
          "meta": {
            "version": 0,
            "created": 1415467401386,
            "revision": 0
          },
          "$loki": 1
        }, {
          "name": "jack",
          "objType": "users",
          "meta": {
            "version": 0,
            "created": 1415467401388,
            "revision": 0
          },
          "$loki": 2
        }],
        "idIndex": [1, 2],
        "binaryIndices": {},
        "objType": "users",
        "transactional": false,
        "cachedIndex": null,
        "cachedBinaryIndex": null,
        "cachedData": null,
        "maxId": 2,
        "DynamicViews": [],
        "events": {
          "insert": [null],
          "update": [null],
          "close": [],
          "flushbuffer": [],
          "error": [],
          "delete": []
        }
      }],
      "events": {
        "close": []
      },
      "ENV": "NODEJS",
      "fs": {}
    };
 
    db.loadJSON(JSON.stringify(json), {
      users: {
        proto: User
      }
    });
 
    users = db.getCollection('users');
    //suite.assertEqual('Inflated object prototype', users.get(1) instanceof User, true);
    expect(users.get(1) instanceof User).toBe(true);
  });
});