本文整理匯總了TypeScript中@angular-devkit/schematics.HostSink類的典型用法代碼示例。如果您正苦於以下問題:TypeScript HostSink類的具體用法?TypeScript HostSink怎麽用?TypeScript HostSink使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了HostSink類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('works', done => {
const host = new virtualFs.test.TestHost({
'/hello': 'world',
'/sub/directory/file2': '',
'/sub/file1': '',
});
const tree = new HostCreateTree(host);
tree.create('/test', 'testing 1 2');
const recorder = tree.beginUpdate('/test');
recorder.insertLeft(8, 'testing ');
tree.commitUpdate(recorder);
const files = ['/hello', '/sub/directory/file2', '/sub/file1', '/test'];
const treeFiles: string[] = [];
tree.visit(path => treeFiles.push(path));
treeFiles.sort();
expect(treeFiles).toEqual(files);
const outputHost = new virtualFs.test.TestHost();
const sink = new HostSink(outputHost);
sink.commit(optimize(tree))
.toPromise()
.then(() => {
const tmpFiles = outputHost.files.sort();
expect(tmpFiles as string[]).toEqual(files);
expect(outputHost.sync.read(normalize('/test')).toString())
.toBe('testing testing 1 2');
})
.then(done, done.fail);
});
示例2: beforeEach
beforeEach(done => {
// Commit a version of the tree.
const host = new virtualFs.test.TestHost({
'/file0': '/file0',
'/sub/directory/file2': '/sub/directory/file2',
'/sub/file1': '/sub/file1',
});
const tree = new HostCreateTree(host);
const outputHost = new virtualFs.test.TestHost();
const sink = new HostSink(outputHost);
sink.commit(optimize(tree))
.toPromise()
.then(done, done.fail);
});
示例3: it
it('can rename files', done => {
const host = new virtualFs.test.TestHost({
'/file0': '/file0',
});
const tree = new FileSystemTree(host);
tree.rename('/file0', '/file1');
const sink = new HostSink(host);
sink.commit(optimize(tree))
.toPromise()
.then(() => {
expect(host.sync.exists(normalize('/file0'))).toBe(false);
expect(host.sync.exists(normalize('/file1'))).toBe(true);
})
.then(done, done.fail);
});