本文整理匯總了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(() => {