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'); });
it('should resolve when the file is reverted for the first time', (done) => { manager.contents.save(context.path, { type: factory.contentType, format: factory.fileFormat, content: 'foo' }); context.ready.then(done, done); context.revert().catch(done); });
it('should normalize CRLF line endings to LF', async () => { await context.initialize(true); await manager.contents.save(context.path, { type: factory.contentType, format: factory.fileFormat, content: 'foo\r\nbar' }); await context.revert(); expect(context.model.toString()).to.equal('foo\nbar'); });
it('should restore the value to the last checkpoint value', async () => { context.model.fromString('bar'); await context.initialize(true); const model = await context.createCheckpoint(); context.model.fromString('foo'); const id = model.id; await context.save(); await context.restoreCheckpoint(id); await context.revert(); expect(context.model.toString()).to.equal('bar'); });
it('should should preserve CRLF line endings upon save', async () => { await context.initialize(true); await manager.contents.save(context.path, { type: factory.contentType, format: factory.fileFormat, content: 'foo\r\nbar' }); await context.revert(); await context.save(); const opts: Contents.IFetchOptions = { format: factory.fileFormat, type: factory.contentType, content: true }; const model = await manager.contents.get(context.path, opts); expect(model.content).to.equal('foo\r\nbar'); });
}).then(() => { return context.revert(); }).then(() => {
}).then(() => { context.model.fromString('bar'); return context.revert(); }).then(() => {