it('should revert to the file on disk', (done) => {
   context.model.fromString('foo');
   context.save().then(() => {
     context.fileChanged.connect(() => {
       expect(context.model.toString()).to.be('bar');
       done();
     });
     setTimeout(() => {
       manager.contents.save(context.path, {
         type: factory.contentType,
         format: factory.fileFormat,
         content: 'bar'
       }).catch(done);
       handler.saveInterval = 1;
       handler.start();
       context.model.fromString('baz');
     }, 1500);  // The server has a one second resolution for saves.
   }).catch(done);
   waitForDialog().then(() => {
     let dialog = document.body.getElementsByClassName('jp-Dialog')[0];
     let buttons = dialog.getElementsByTagName('button');
     for (let i = 0; i < buttons.length; i++) {
       if (buttons[i].textContent === 'REVERT') {
         buttons[i].click();
       }
     }
   });
 });
 it('should be set after poulation', (done) => {
   context.ready.then(() => {
     expect(context.contentsModel.name).to.be('foo');
     done();
   });
   context.save().catch(done);
 });
Exemple #3
0
 it('should create a checkpoint for the file', () => {
   return context.save().then(() => {
     return context.createCheckpoint();
   }).then(model => {
     expect(model.id).to.be.ok();
     expect(model.last_modified).to.be.ok();
   });
 });
Exemple #4
0
 it('should revert the contents of the file to the disk', async () => {
   await context.initialize(true);
   context.model.fromString('foo');
   await context.save();
   context.model.fromString('bar');
   await context.revert();
   expect(context.model.toString()).to.equal('foo');
 });
Exemple #5
0
 it('should indicate whether the context is ready', (done) => {
   expect(context.isReady).to.be(false);
   context.ready.then(() => {
     expect(context.isReady).to.be(true);
     done();
   }).catch(done);
   context.save().catch(done);
 });
 it('should be emitted when the file is saved', (done) => {
   context.fileChanged.connect((sender, args) => {
     expect(sender).to.be(context);
     expect(args.name).to.be('foo');
     done();
   });
   context.save();
 });
Exemple #7
0
 it('should be set after poulation', (done) => {
   let path = context.path;
   context.ready.then(() => {
     expect(context.contentsModel.path).to.be(path);
     done();
   });
   context.save().catch(done);
 });
Exemple #8
0
 it('should just save if the file name does not change', () => {
   acceptDialog();
   let path = context.path;
   return context.save().then(() => {
     return context.saveAs();
   }).then(() => {
     expect(context.path).to.be(path);
   });
 });
Exemple #9
0
 it('should be emitted when the file is saved', (done) => {
   let path = context.path;
   context.fileChanged.connect((sender, args) => {
     expect(sender).to.be(context);
     expect(args.path).to.be(path);
     done();
   });
   context.save().catch(done);
 });
 it('should be emitted when the path changes', (done) => {
   context.pathChanged.connect((sender, args) => {
     expect(sender).to.be(context);
     expect(args).to.be('foo');
     done();
   });
   context.save().then(() => {
     return manager.contents.rename(context.path, 'foo');
   }).catch(done);
 });