當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript common.PercentPipe類代碼示例

本文整理匯總了TypeScript中@angular/common.PercentPipe的典型用法代碼示例。如果您正苦於以下問題:TypeScript PercentPipe類的具體用法?TypeScript PercentPipe怎麽用?TypeScript PercentPipe使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PercentPipe類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

      describe('PercentPipe', () => {
        var pipe: PercentPipe;

        beforeEach(() => { pipe = new PercentPipe(); });

        describe('transform', () => {
          it('should return correct value for numbers', () => {
            expect(pipe.transform(1.23)).toEqual('123%');
            expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
          });

          it('should not support other objects',
             () => { expect(() => pipe.transform(new Object())).toThrowError(); });
        });
      });
開發者ID:AngularLovers,項目名稱:angular,代碼行數:15,代碼來源:number_pipe_spec.ts

示例2: describe

    describe('PercentPipe', () => {
      let pipe: PercentPipe;

      beforeEach(() => { pipe = new PercentPipe('en-US'); });

      describe('transform', () => {
        it('should return correct value for numbers', () => {
          expect(pipe.transform(1.23)).toEqual('123%');
          expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
          expect(pipe.transform(1.2, '4.2')).toEqual('0,120.00%');
          expect(pipe.transform(1.2, '4.2', 'fr')).toEqual('0 120,00 %');
        });

        it('should not support other objects',
           () => { expect(() => pipe.transform({})).toThrowError(); });
      });
    });
開發者ID:MarkPieszak,項目名稱:angular,代碼行數:17,代碼來源:number_pipe_spec.ts

示例3: describe

    describe('PercentPipe', () => {
      let pipe: PercentPipe;

      beforeEach(() => { pipe = new PercentPipe('en-US'); });

      describe('transform', () => {
        it('should return correct value for numbers', () => {
          expect(pipe.transform(1.23)).toEqual('123%');
          expect(pipe.transform(12.3456, '0.0-10')).toEqual('1,234.56%');
        });

        it('should not support other objects', () => {
          expect(() => pipe.transform({}))
              .toThrowError(
                  `InvalidPipeArgument: '[object Object] is not a number' for pipe 'PercentPipe'`);
        });
      });
    });
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:18,代碼來源:number_pipe_spec.ts

示例4: describe

    describe('PercentPipe', () => {
      let pipe: PercentPipe;

      beforeEach(() => { pipe = new PercentPipe('en-US'); });

      describe('transform', () => {
        it('should return correct value for numbers', () => {
          expect(pipe.transform(1.23)).toEqual('123%');
          expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
          expect(pipe.transform(1.2, '4.2')).toEqual('0,120.00%');
          expect(pipe.transform(1.2, '4.2', 'fr')).toEqual('0 120,00 %');
          expect(pipe.transform(1.2, '4.2', 'ar')).toEqual('0,120.00‎%‎');
          // see issue #20136
          expect(pipe.transform(0.12345674, '0.0-10')).toEqual('12.345674%');
          expect(pipe.transform(0, '0.0-10')).toEqual('0%');
          expect(pipe.transform(0.00, '0.0-10')).toEqual('0%');
          expect(pipe.transform(1, '0.0-10')).toEqual('100%');
          expect(pipe.transform(0.1, '0.0-10')).toEqual('10%');
          expect(pipe.transform(0.12, '0.0-10')).toEqual('12%');
          expect(pipe.transform(0.123, '0.0-10')).toEqual('12.3%');
          expect(pipe.transform(12.3456, '0.0-10')).toEqual('1,234.56%');
          expect(pipe.transform(12.345600, '0.0-10')).toEqual('1,234.56%');
          expect(pipe.transform(12.345699999, '0.0-6')).toEqual('1,234.57%');
          expect(pipe.transform(12.345699999, '0.4-6')).toEqual('1,234.5700%');
          expect(pipe.transform(100, '0.4-6')).toEqual('10,000.0000%');
          expect(pipe.transform(100, '0.0-10')).toEqual('10,000%');
          expect(pipe.transform(1.5e2)).toEqual('15,000%');
          expect(pipe.transform(1e100)).toEqual('1E+102%');
        });

        it('should not support other objects', () => {
          expect(() => pipe.transform({}))
              .toThrowError(
                  `InvalidPipeArgument: '[object Object] is not a number' for pipe 'PercentPipe'`);
        });
      });
    });
開發者ID:gautamkrishnar,項目名稱:angular,代碼行數:37,代碼來源:number_pipe_spec.ts

示例5: expect

 () => { expect(() => pipe.transform(new Object())).toThrowError(); });
開發者ID:AngularLovers,項目名稱:angular,代碼行數:1,代碼來源:number_pipe_spec.ts

示例6: it

 it('should return correct value for numbers', () => {
   expect(pipe.transform(1.23)).toEqual('123%');
   expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
 });
開發者ID:AngularLovers,項目名稱:angular,代碼行數:4,代碼來源:number_pipe_spec.ts

示例7: expect

 expect(() => pipe.transform({}))
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:1,代碼來源:number_pipe_spec.ts

示例8: it

 it('should return correct value for numbers', () => {
   expect(pipe.transform(1.23)).toEqual('123%');
   expect(pipe.transform(12.3456, '0.0-10')).toEqual('1,234.56%');
 });
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:4,代碼來源:number_pipe_spec.ts

示例9: it

 it('should return correct value for numbers', () => {
   expect(pipe.transform(1.23)).toEqual('123%');
   expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
   expect(pipe.transform(1.2, '4.2')).toEqual('0,120.00%');
   expect(pipe.transform(1.2, '4.2', 'fr')).toEqual('0 120,00 %');
   // see issue #20136
   expect(pipe.transform(0.12345674, '0.0-10')).toEqual('12.345674%');
   expect(pipe.transform(0, '0.0-10')).toEqual('0%');
   expect(pipe.transform(0.00, '0.0-10')).toEqual('0%');
   expect(pipe.transform(1, '0.0-10')).toEqual('100%');
   expect(pipe.transform(0.1, '0.0-10')).toEqual('10%');
   expect(pipe.transform(0.12, '0.0-10')).toEqual('12%');
   expect(pipe.transform(0.123, '0.0-10')).toEqual('12.3%');
   expect(pipe.transform(12.3456, '0.0-10')).toEqual('1,234.56%');
   expect(pipe.transform(12.345600, '0.0-10')).toEqual('1,234.56%');
   expect(pipe.transform(12.345699999, '0.0-6')).toEqual('1,234.57%');
   expect(pipe.transform(12.345699999, '0.4-6')).toEqual('1,234.5700%');
   expect(pipe.transform(100, '0.4-6')).toEqual('10,000.0000%');
   expect(pipe.transform(100, '0.0-10')).toEqual('10,000%');
   expect(pipe.transform(1.5e2)).toEqual('15,000%');
   expect(pipe.transform(1e100)).toEqual('1E+102%');
 });
開發者ID:Rowmance,項目名稱:angular,代碼行數:22,代碼來源:number_pipe_spec.ts

示例10: expect

 () => { expect(() => pipe.transform({})).toThrowError(); });
開發者ID:MarkPieszak,項目名稱:angular,代碼行數:1,代碼來源:number_pipe_spec.ts


注:本文中的@angular/common.PercentPipe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。