add spies for l10n warnings

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2017-01-13 11:20:19 +01:00
parent 00c3f807db
commit 9d56d5e94d
1 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,7 @@ describe('OC.L10N tests', function() {
describe('text translation', function() { describe('text translation', function() {
beforeEach(function() { beforeEach(function() {
spyOn(console, 'warn');
OC.L10N.register(TEST_APP, { OC.L10N.register(TEST_APP, {
'Hello world!': 'Hallo Welt!', 'Hello world!': 'Hallo Welt!',
'Hello {name}, the weather is {weather}': 'Hallo {name}, das Wetter ist {weather}', 'Hello {name}, the weather is {weather}': 'Hallo {name}, das Wetter ist {weather}',
@ -78,8 +79,10 @@ describe('OC.L10N tests', function() {
} }
it('generates plural for default text when translation does not exist', function() { it('generates plural for default text when translation does not exist', function() {
spyOn(console, 'warn');
OC.L10N.register(TEST_APP, { OC.L10N.register(TEST_APP, {
}); });
expect(console.warn).toHaveBeenCalled();
expect( expect(
n(TEST_APP, 'download %n file', 'download %n files', 0) n(TEST_APP, 'download %n file', 'download %n files', 0)
).toEqual('download 0 files'); ).toEqual('download 0 files');
@ -94,10 +97,12 @@ describe('OC.L10N tests', function() {
).toEqual('download 1024 files'); ).toEqual('download 1024 files');
}); });
it('generates plural with default function when no forms specified', function() { it('generates plural with default function when no forms specified', function() {
spyOn(console, 'warn');
OC.L10N.register(TEST_APP, { OC.L10N.register(TEST_APP, {
'_download %n file_::_download %n files_': '_download %n file_::_download %n files_':
['%n Datei herunterladen', '%n Dateien herunterladen'] ['%n Datei herunterladen', '%n Dateien herunterladen']
}); });
expect(console.warn).toHaveBeenCalled();
checkPlurals(); checkPlurals();
}); });
it('generates plural with generated function when forms is specified', function() { it('generates plural with generated function when forms is specified', function() {
@ -150,9 +155,11 @@ describe('OC.L10N tests', function() {
it('calls callback if translation already available', function() { it('calls callback if translation already available', function() {
var promiseStub = sinon.stub(); var promiseStub = sinon.stub();
var callbackStub = sinon.stub(); var callbackStub = sinon.stub();
spyOn(console, 'warn');
OC.L10N.register(TEST_APP, { OC.L10N.register(TEST_APP, {
'Hello world!': 'Hallo Welt!' 'Hello world!': 'Hallo Welt!'
}); });
expect(console.warn).toHaveBeenCalled();
OC.L10N.load(TEST_APP, callbackStub).then(promiseStub); OC.L10N.load(TEST_APP, callbackStub).then(promiseStub);
expect(callbackStub.calledOnce).toEqual(true); expect(callbackStub.calledOnce).toEqual(true);
expect(promiseStub.calledOnce).toEqual(true); expect(promiseStub.calledOnce).toEqual(true);