"Fossies" - the Fresh Open Source Software Archive

Member "angular-cli-8.3.23/packages/angular_devkit/core/src/virtual-fs/host/alias_spec.ts" (15 Jan 2020, 2091 Bytes) of package /linux/www/angular-cli-8.3.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /**
    2  * @license
    3  * Copyright Google Inc. All Rights Reserved.
    4  *
    5  * Use of this source code is governed by an MIT-style license that can be
    6  * found in the LICENSE file at https://angular.io/license
    7  */
    8 import { normalize } from '..';
    9 import { AliasHost } from './alias';
   10 import { stringToFileBuffer } from './buffer';
   11 import { SimpleMemoryHost } from './memory';
   12 
   13 describe('AliasHost', () => {
   14   it('works as in the example', () => {
   15     const content = stringToFileBuffer('hello world');
   16 
   17     const host = new SimpleMemoryHost();
   18     host.write(normalize('/some/file'), content).subscribe();
   19 
   20     const aHost = new AliasHost(host);
   21     aHost.read(normalize('/some/file'))
   22       .subscribe(x => expect(x).toBe(content));
   23     aHost.aliases.set(normalize('/some/file'), normalize('/other/path'));
   24 
   25     // This file will not exist because /other/path does not exist.
   26     try {
   27       aHost.read(normalize('/some/file'))
   28         .subscribe(undefined, err => {
   29           expect(err.message).toMatch(/does not exist/);
   30         });
   31     } catch {
   32       // Ignore it. RxJS <6 still throw errors when they happen synchronously.
   33     }
   34   });
   35 
   36   it('works as in the example (2)', () => {
   37     const content = stringToFileBuffer('hello world');
   38     const content2 = stringToFileBuffer('hello world 2');
   39 
   40     const host = new SimpleMemoryHost();
   41     host.write(normalize('/some/folder/file'), content).subscribe();
   42 
   43     const aHost = new AliasHost(host);
   44     aHost.read(normalize('/some/folder/file'))
   45         .subscribe(x => expect(x).toBe(content));
   46     aHost.aliases.set(normalize('/some'), normalize('/other'));
   47 
   48     // This file will not exist because /other/path does not exist.
   49     try {
   50       aHost.read(normalize('/some/folder/file'))
   51         .subscribe(undefined, err => expect(err.message).toMatch(/does not exist/));
   52     } catch {}
   53 
   54     // Create the file with new content and verify that this has the new content.
   55     aHost.write(normalize('/other/folder/file'), content2).subscribe();
   56     aHost.read(normalize('/some/folder/file'))
   57         .subscribe(x => expect(x).toBe(content2));
   58   });
   59 });