本文整理汇总了TypeScript中@jupyterlab/docregistry.Context.saveAs方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context.saveAs方法的具体用法?TypeScript Context.saveAs怎么用?TypeScript Context.saveAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/docregistry.Context
的用法示例。
在下文中一共展示了Context.saveAs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should just save if the file name does not change', async () => {
const path = context.path;
await context.initialize(true);
const promise = context.saveAs();
await acceptDialog();
await promise;
expect(context.path).to.equal(path);
});
示例2: it
it('should save the document to a different path chosen by the user', (done) => {
waitForDialog().then(() => {
let dialog = document.body.getElementsByClassName('jp-Dialog')[0];
let input = dialog.getElementsByTagName('input')[0];
input.value = 'bar';
acceptDialog();
});
context.saveAs().then(() => {
expect(context.path).to.be('bar');
done();
}).catch(done);
});
示例3: it
it('should keep the file if overwrite is aborted', async () => {
const oldPath = context.path;
const newPath = UUID.uuid4() + '.txt';
const func = async () => {
await waitForDialog();
const dialog = document.body.getElementsByClassName('jp-Dialog')[0];
const input = dialog.getElementsByTagName('input')[0];
input.value = newPath;
await acceptDialog(); // Accept rename dialog
await dismissDialog(); // Reject conflict dialog
};
await manager.contents.save(newPath, {
type: factory.contentType,
format: factory.fileFormat,
content: 'foo'
});
await context.initialize(true);
const promise = func();
await context.saveAs();
await promise;
expect(context.path).to.equal(oldPath);
});
示例4:
return context.initialize(true).then(() => {
return context.saveAs();
}).then(() => {
示例5:
return initialize.then(() => context.saveAs()).then(() => {