diff --git a/apps/files/tests/js/fileUploadSpec.js b/apps/files/tests/js/fileUploadSpec.js index aa8357bf26b0..946ac2a8cc45 100644 --- a/apps/files/tests/js/fileUploadSpec.js +++ b/apps/files/tests/js/fileUploadSpec.js @@ -133,7 +133,7 @@ describe('OC.Upload tests', function() { '' + 'Name' + '' + '' + '' + diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 48bddc13efb0..0463a50eaa59 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -94,7 +94,7 @@ describe('OCA.Files.FileList tests', function() { '' + 'Name' + '' + '' + '' + diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index e096fda1d5ef..0f3f76f919e3 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -182,6 +182,7 @@ window.isPhantom = /phantom/i.test(navigator.userAgent); // reset pop state handlers OC.Util.History._handlers = []; + $(window).off('beforeunload'); }); })(); diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 659b67fe5aa4..886ac5c24cd7 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -994,7 +994,12 @@ describe('Core base tests', function() { var $rows = $el.find('.row'); expect($rows.length).toEqual(2); + // when called without arguments, a warning to be logged + // to ask devs to adjust their usage of the API. + // we stub it to avoid polluting the actual console + var warnStub = sinon.stub(console, 'warn'); OC.Notification.hide(); + warnStub.restore(); $rows = $el.find('.row'); expect($rows.length).toEqual(1); diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js index 2ceb2f4a916b..c2ef996d0494 100644 --- a/core/js/tests/specs/l10nSpec.js +++ b/core/js/tests/specs/l10nSpec.js @@ -7,7 +7,6 @@ * See the COPYING-README file. * */ - describe('OC.L10N tests', function() { var TEST_APP = 'jsunittestapp'; @@ -25,7 +24,7 @@ describe('OC.L10N tests', function() { 'Hello world!': 'Hallo Welt!', 'Hello {name}, the weather is {weather}': 'Hallo {name}, das Wetter ist {weather}', 'sunny': 'sonnig' - }); + }, 'nplurals=2; plural=(n != 1);'); }); it('returns untranslated text when no bundle exists', function() { delete OC.L10N._bundles[TEST_APP]; @@ -56,12 +55,21 @@ describe('OC.L10N tests', function() { OC.L10N.register(TEST_APP, { 'sunny': 'sonnig', 'new': 'neu' - }); + }, 'nplurals=2; plural=(n != 1);'); expect(t(TEST_APP, 'sunny')).toEqual('sonnig'); expect(t(TEST_APP, 'new')).toEqual('neu'); }); }); describe('plurals', function() { + var warnStub; + + beforeEach(function() { + warnStub = sinon.stub(console, 'warn'); + }); + afterEach(function() { + warnStub.restore(); + }); + function checkPlurals() { expect( n(TEST_APP, 'download %n file', 'download %n files', 0) @@ -80,6 +88,7 @@ describe('OC.L10N tests', function() { it('generates plural for default text when translation does not exist', function() { OC.L10N.register(TEST_APP, { }); + expect(warnStub.called).toEqual(true); expect( n(TEST_APP, 'download %n file', 'download %n files', 0) ).toEqual('download 0 files'); @@ -98,6 +107,7 @@ describe('OC.L10N tests', function() { '_download %n file_::_download %n files_': ['%n Datei herunterladen', '%n Dateien herunterladen'] }); + expect(warnStub.called).toEqual(true); checkPlurals(); }); it('generates plural with generated function when forms is specified', function() { @@ -105,6 +115,7 @@ describe('OC.L10N tests', function() { '_download %n file_::_download %n files_': ['%n Datei herunterladen', '%n Dateien herunterladen'] }, 'nplurals=2; plural=(n != 1);'); + expect(warnStub.notCalled).toEqual(true); checkPlurals(); }); it('generates plural with function when forms is specified as function', function() { @@ -117,6 +128,7 @@ describe('OC.L10N tests', function() { plural: (n !== 1) ? 1 : 0 }; }); + expect(warnStub.notCalled).toEqual(true); checkPlurals(); }); }); @@ -152,7 +164,7 @@ describe('OC.L10N tests', function() { var callbackStub = sinon.stub(); OC.L10N.register(TEST_APP, { 'Hello world!': 'Hallo Welt!' - }); + }, 'nplurals=2; plural=(n != 1);'); OC.L10N.load(TEST_APP, callbackStub).then(promiseStub); expect(callbackStub.calledOnce).toEqual(true); expect(promiseStub.calledOnce).toEqual(true);