Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce JS test warnings #28772

Merged
merged 2 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files/tests/js/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('OC.Upload tests', function() {
'<input type="checkbox" id="select_all_files" class="select-all">' +
'<a class="name columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' +
'<span id="selectedActionsList" class="selectedActions hidden">' +
'<a href class="download"><img src="actions/download.svg">Download</a>' +
'<a href class="download"><img/>Download</a>' +
'<a href class="delete-selected">Delete</a></span>' +
'</th>' +
'<th class="hidden column-size"><a class="columntitle" data-sort="size"><span class="sort-indicator"></span></a></th>' +
Expand Down
2 changes: 1 addition & 1 deletion apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('OCA.Files.FileList tests', function() {
'<input type="checkbox" id="select_all_files" class="select-all checkbox">' +
'<a class="name columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' +
'<span id="selectedActionsList" class="selectedActions hidden">' +
'<a href class="download"><img src="actions/download.svg">Download</a>' +
'<a href class="download"><img/>Download</a>' +
'<a href class="delete-selected">Delete</a></span>' +
'</th>' +
'<th class="hidden column-size"><a class="columntitle" data-sort="size"><span class="sort-indicator"></span></a></th>' +
Expand Down
1 change: 1 addition & 0 deletions core/js/tests/specHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ window.isPhantom = /phantom/i.test(navigator.userAgent);
// reset pop state handlers
OC.Util.History._handlers = [];

$(window).off('beforeunload');
});
})();

5 changes: 5 additions & 0 deletions core/js/tests/specs/coreSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 16 additions & 4 deletions core/js/tests/specs/l10nSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* See the COPYING-README file.
*
*/

describe('OC.L10N tests', function() {
var TEST_APP = 'jsunittestapp';

Expand All @@ -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];
Expand Down Expand Up @@ -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)
Expand All @@ -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');
Expand All @@ -98,13 +107,15 @@ 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() {
OC.L10N.register(TEST_APP, {
'_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() {
Expand All @@ -117,6 +128,7 @@ describe('OC.L10N tests', function() {
plural: (n !== 1) ? 1 : 0
};
});
expect(warnStub.notCalled).toEqual(true);
checkPlurals();
});
});
Expand Down Expand Up @@ -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);
Expand Down