Skip to content

Commit acf8687

Browse files
committed
remove useless ngettext
1 parent c04abcb commit acf8687

File tree

3 files changed

+4
-61
lines changed

3 files changed

+4
-61
lines changed

lib/utils.js

-32
Original file line numberDiff line numberDiff line change
@@ -753,38 +753,6 @@ exports.dQuote = function(str) {
753753
return '"' + str + '"';
754754
};
755755

756-
/**
757-
* Provides simplistic message translation for dealing with plurality.
758-
*
759-
* @description
760-
* Use this to create messages which need to be singular or plural.
761-
* Some languages have several plural forms, so _complete_ message clauses
762-
* are preferable to generating the message on the fly.
763-
*
764-
* @private
765-
* @param {number} n - Non-negative integer
766-
* @param {string} msg1 - Message to be used in English for `n = 1`
767-
* @param {string} msg2 - Message to be used in English for `n = 0, 2, 3, ...`
768-
* @returns {string} message corresponding to value of `n`
769-
* @example
770-
* var sprintf = require('util').format;
771-
* var pkgs = ['one', 'two'];
772-
* var msg = sprintf(
773-
* ngettext(
774-
* pkgs.length,
775-
* 'cannot load package: %s',
776-
* 'cannot load packages: %s'
777-
* ),
778-
* pkgs.map(sQuote).join(', ')
779-
* );
780-
* console.log(msg); // => cannot load packages: 'one', 'two'
781-
*/
782-
exports.ngettext = function(n, msg1, msg2) {
783-
if (typeof n === 'number' && n >= 0) {
784-
return n === 1 ? msg1 : msg2;
785-
}
786-
};
787-
788756
/**
789757
* It's a noop.
790758
* @public

test/unit/runner.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('Runner', function() {
121121
global.foo = 'bar';
122122
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
123123
expect(_test, 'to be', test);
124-
expect(_err, 'to have message', "global leak detected: 'foo'");
124+
expect(_err, 'to have message', "global leak(s) detected: 'foo'");
125125
delete global.foo;
126126
done();
127127
});
@@ -183,7 +183,7 @@ describe('Runner', function() {
183183
global.bar = 'baz';
184184
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
185185
expect(_test, 'to be', test);
186-
expect(_err, 'to have message', "global leaks detected: 'foo', 'bar'");
186+
expect(_err.message, 'to be', "global leak(s) detected: 'foo', 'bar'");
187187
delete global.foo;
188188
delete global.bar;
189189
done();
@@ -217,7 +217,7 @@ describe('Runner', function() {
217217
global.bar = 'detect-me';
218218
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
219219
expect(_test.title, 'to be', 'im a test about lions');
220-
expect(_err, 'to have message', "global leak detected: 'bar'");
220+
expect(_err, 'to have message', "global leak(s) detected: 'bar'");
221221
delete global.foo;
222222
delete global.bar;
223223
done();
@@ -229,7 +229,7 @@ describe('Runner', function() {
229229
global.derp = 'bar';
230230
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
231231
expect(_test.title, 'to be', 'herp');
232-
expect(_err, 'to have message', "global leak detected: 'derp'");
232+
expect(_err, 'to have message', "global leak(s) detected: 'derp'");
233233
delete global.derp;
234234
done();
235235
});

test/unit/utils.spec.js

-25
Original file line numberDiff line numberDiff line change
@@ -724,31 +724,6 @@ describe('lib/utils', function() {
724724
});
725725
});
726726

727-
describe('ngettext', function() {
728-
var singular = 'singular';
729-
var plural = 'plural';
730-
731-
it("should return plural string if 'n' is 0", function() {
732-
expect(utils.ngettext(0, singular, plural), 'to be', plural);
733-
});
734-
735-
it("should return singular string if 'n' is 1", function() {
736-
expect(utils.ngettext(1, singular, plural), 'to be', singular);
737-
});
738-
739-
it("should return plural string if 'n' is greater than 1", function() {
740-
var arr = ['aaa', 'bbb'];
741-
expect(utils.ngettext(arr.length, singular, plural), 'to be', plural);
742-
});
743-
744-
it("should return undefined if 'n' is not a non-negative integer", function() {
745-
expect(utils.ngettext('', singular, plural), 'to be undefined');
746-
expect(utils.ngettext(-1, singular, plural), 'to be undefined');
747-
expect(utils.ngettext(true, singular, plural), 'to be undefined');
748-
expect(utils.ngettext({}, singular, plural), 'to be undefined');
749-
});
750-
});
751-
752727
describe('createMap', function() {
753728
it('should return an object with a null prototype', function() {
754729
expect(Object.getPrototypeOf(utils.createMap()), 'to be', null);

0 commit comments

Comments
 (0)