Skip to content

Commit

Permalink
Add methods for exposing internal state
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed May 6, 2020
1 parent e507706 commit fe262ec
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pluralize.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,41 @@
irregularPlurals[plural] = single;
};

/**
* Get all known plural rules.
*/
pluralize.getPluralRules = function () {
return pluralRules;
};

/**
* Get all known singular rules.
*/
pluralize.getSingularRules = function () {
return singularRules;
};

/**
* Get all known uncountable words.
*/
pluralize.getUncountables = function () {
return uncountables;
};

/**
* Get all known irregular plural words.
*/
pluralize.getIrregularPlurals = function () {
return irregularPlurals;
};

/**
* Get all known irregular single words.
*/
pluralize.getIrregularSingles = function () {
return irregularSingles;
};

/**
* Irregular rules.
*/
Expand Down
31 changes: 31 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,4 +833,35 @@ describe('pluralize', function () {
expect(pluralize.singular('mornings')).to.equal('suck');
});
});

describe('getting existing rules', function () {
it('should allow access to plural rules', function () {
var rules = pluralize.getPluralRules();
expect(rules).to.be.an('array');
});

it('should allow access to singular rules', function () {
var rules = pluralize.getSingularRules();
expect(rules).to.be.an('array');
});
});

describe('getting uncountable words', function () {
it('should allow access to uncountable words', function () {
var uncountable = pluralize.getUncountables();
expect(uncountable).to.be.ok.and.an('object');
});
});

describe('getting irregular words', function () {
it('should allow access to irregular plural words', function () {
var irregular = pluralize.getIrregularPlurals();
expect(irregular).to.be.ok.and.an('object');
});

it('should allow access to irregular singular words', function () {
var irregular = pluralize.getIrregularSingles();
expect(irregular).to.be.ok.and.an('object');
});
});
});

0 comments on commit fe262ec

Please sign in to comment.