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

Statements: 100% (15 / 15)      Branches: 50% (1 / 2)      Functions: 100% (3 / 3)      Lines: 100% (14 / 14)      Ignored: none     

All files » spec/generic/ » stage.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 441   1 1 1           1                             1   1       1       1 1 1 1 1 1      
Eif (typeof (window) === 'undefined') var loki = require('../../src/lokijs.js');
 
describe('Staging and commits', function () {
  beforeEach(function () {
    db = new loki('testJoins', {
        persistenceMethod: null
      }),
      directors = db.addCollection('directors'),
      films = db.addCollection('films');
 
    directors.insert([{
      name: 'Martin Scorsese',
      directorId: 1
    }, {
      name: 'Francis Ford Coppola',
      directorId: 2
    }, {
      name: 'Steven Spielberg',
      directorId: 3
    }, {
      name: 'Quentin Tarantino',
      directorId: 4
    }]);
  });
 
  it('work', function () {
 
    var stageName = 'tentative directors',
      newDirectorsName = 'Joel and Ethan Cohen',
      message = 'Edited Cohen brothers name';
 
    var cohen = directors.insert({
      name: 'Cohen Brothers',
      directorId: 5
    });
    var new_cohen = directors.stage(stageName, cohen);
    new_cohen.name = newDirectorsName;
    expect(cohen.name).toEqual('Cohen Brothers');
    directors.commitStage(stageName, message);
    expect(directors.get(cohen.$loki).name).toEqual('Joel and Ethan Cohen');
    expect(directors.commitLog[0].message).toEqual(message);
  });
});