TypeScript @angular-compiler-src-view_resolver.ViewResolver类(方法)实例源码

下面列出了TypeScript @angular-compiler-src-view_resolver.ViewResolver 类(方法)源码代码实例,从而了解它的用法。

作者:4vange    项目:angula   
describe('ViewResolver', () => {
    var resolver: ViewResolver;

    beforeEach(() => { resolver = new ViewResolver(); });

    it('should read out the View metadata from the Component metadata', () => {
      var viewMetadata = resolver.resolve(ComponentWithTemplate);
      expect(viewMetadata).toEqual(new ViewMetadata({
        template: 'some template',
        directives: [SomeDir],
        pipes: [SomePipe],
        styles: ['some styles']
      }));
    });

    it('should throw when Component has neither template nor templateUrl set', () => {
      expect(() => resolver.resolve(ComponentWithoutView))
          .toThrowError(
              /Component 'ComponentWithoutView' must have either 'template' or 'templateUrl' set/);
    });

    it('should throw when simple class has no component decorator', () => {
      expect(() => resolver.resolve(SimpleClass))
          .toThrowError('Could not compile \'SimpleClass\' because it is not a component.');
    });
  });

作者:0xJoK    项目:angula   
describe("ViewResolver", () => {
    var resolver: ViewResolver;

    beforeEach(() => { resolver = new ViewResolver(); });

    it('should read out the View metadata from the Component metadata', () => {
      var viewMetadata = resolver.resolve(ComponentWithTemplate);
      expect(viewMetadata)
          .toEqual(new ViewMetadata({
            template: "some template",
            directives: [SomeDir],
            pipes: [SomePipe],
            styles: ["some styles"]
          }));
    });

    it('should throw when Component has no View decorator and no template is set', () => {
      expect(() => resolver.resolve(ComponentWithoutView))
          .toThrowErrorWith(
              "Component 'ComponentWithoutView' must have either 'template' or 'templateUrl' set");
    });

    it('should throw when simple class has no View decorator and no template is set', () => {
      expect(() => resolver.resolve(SimpleClass))
          .toThrowErrorWith("Could not compile 'SimpleClass' because it is not a component.");
    });
  });

作者:4vange    项目:angula   
it('should read out the View metadata from the Component metadata', () => {
   var viewMetadata = resolver.resolve(ComponentWithTemplate);
   expect(viewMetadata).toEqual(new ViewMetadata({
     template: 'some template',
     directives: [SomeDir],
     pipes: [SomePipe],
     styles: ['some styles']
   }));
 });

作者:4vange    项目:angula   
expect(() => resolver.resolve(SimpleClass))


问题


面经


文章

微信
公众号

扫码关注公众号