chore(test): disable tests based on Intl API in non-Chrome browsers
Closes #3692
This commit is contained in:
@ -21,6 +21,9 @@ import {Pipe} from '../core/metadata';
|
|||||||
var defaultLocale: string = 'en-US';
|
var defaultLocale: string = 'en-US';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* WARNING: this pipe uses the Internationalization API.
|
||||||
|
* Therefore it is only reliable in Chrome and Opera browsers.
|
||||||
|
*
|
||||||
* Formats a date value to a string based on the requested format.
|
* Formats a date value to a string based on the requested format.
|
||||||
*
|
*
|
||||||
* # Usage
|
* # Usage
|
||||||
|
@ -57,6 +57,9 @@ export class NumberPipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* WARNING: this pipe uses the Internationalization API.
|
||||||
|
* Therefore it is only reliable in Chrome and Opera browsers.
|
||||||
|
*
|
||||||
* Formats a number as local text. i.e. group sizing and seperator and other locale-specific
|
* Formats a number as local text. i.e. group sizing and seperator and other locale-specific
|
||||||
* configurations are based on the active locale.
|
* configurations are based on the active locale.
|
||||||
*
|
*
|
||||||
@ -92,6 +95,9 @@ export class DecimalPipe extends NumberPipe implements PipeTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* WARNING: this pipe uses the Internationalization API.
|
||||||
|
* Therefore it is only reliable in Chrome and Opera browsers.
|
||||||
|
*
|
||||||
* Formats a number as local percent.
|
* Formats a number as local percent.
|
||||||
*
|
*
|
||||||
* # Usage
|
* # Usage
|
||||||
@ -111,6 +117,9 @@ export class PercentPipe extends NumberPipe implements PipeTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* WARNING: this pipe uses the Internationalization API.
|
||||||
|
* Therefore it is only reliable in Chrome and Opera browsers.
|
||||||
|
*
|
||||||
* Formats a number as local currency.
|
* Formats a number as local currency.
|
||||||
*
|
*
|
||||||
* # Usage
|
* # Usage
|
||||||
|
@ -85,3 +85,10 @@ export function stringifyElement(el): string {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The Intl API is only properly supported in Chrome and Opera.
|
||||||
|
// Note: Edge is disguised as Chrome 42, so checking the "Edge" part is needed,
|
||||||
|
// see https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
|
||||||
|
export function supportsIntlApi(): boolean {
|
||||||
|
return DOM.getUserAgent().indexOf('Chrome') > -1 && DOM.getUserAgent().indexOf('Edge') == -1;
|
||||||
|
}
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/test_lib';
|
import {
|
||||||
|
ddescribe,
|
||||||
|
describe,
|
||||||
|
it,
|
||||||
|
iit,
|
||||||
|
xit,
|
||||||
|
expect,
|
||||||
|
beforeEach,
|
||||||
|
afterEach,
|
||||||
|
supportsIntlApi
|
||||||
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {DatePipe} from 'angular2/pipes';
|
import {DatePipe} from 'angular2/pipes';
|
||||||
import {DateWrapper} from 'angular2/src/facade/lang';
|
import {DateWrapper} from 'angular2/src/facade/lang';
|
||||||
@ -23,6 +33,9 @@ export function main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO(mlaval): enable tests when Intl API is no longer used, see
|
||||||
|
// https://github.com/angular/angular/issues/3333
|
||||||
|
if (supportsIntlApi()) {
|
||||||
describe("transform", () => {
|
describe("transform", () => {
|
||||||
it('should format each component correctly', () => {
|
it('should format each component correctly', () => {
|
||||||
expect(pipe.transform(date, ['y'])).toEqual('2015');
|
expect(pipe.transform(date, ['y'])).toEqual('2015');
|
||||||
@ -60,5 +73,6 @@ export function main() {
|
|||||||
expect(pipe.transform(date, ['shortTime'])).toEqual('9:43 PM');
|
expect(pipe.transform(date, ['shortTime'])).toEqual('9:43 PM');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/test_lib';
|
import {
|
||||||
|
ddescribe,
|
||||||
|
describe,
|
||||||
|
it,
|
||||||
|
iit,
|
||||||
|
xit,
|
||||||
|
expect,
|
||||||
|
beforeEach,
|
||||||
|
afterEach,
|
||||||
|
supportsIntlApi
|
||||||
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {DecimalPipe, PercentPipe, CurrencyPipe} from 'angular2/pipes';
|
import {DecimalPipe, PercentPipe, CurrencyPipe} from 'angular2/pipes';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
|
// TODO(mlaval): enable tests when Intl API is no longer used, see
|
||||||
|
// https://github.com/angular/angular/issues/3333
|
||||||
|
if (supportsIntlApi()) {
|
||||||
describe("DecimalPipe", () => {
|
describe("DecimalPipe", () => {
|
||||||
var pipe;
|
var pipe;
|
||||||
|
|
||||||
@ -56,3 +69,4 @@ export function main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user