formatjs-helper
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -1,10 +0,13 @@ | ||
/** | ||
* Creates a new helper on a set of data | ||
* @param {Object} data, ICU Message Format {locales: '<locale string>', messages: {...}} | ||
*/ | ||
function FormatJSHelper(data) { | ||
this.data = data; | ||
} | ||
var formatJSHelper = { | ||
/** | ||
* Initialize this helper on a set of data | ||
* Must be called before any other method | ||
* @param {Object} data, ICU Message Format {locales: '<locale string>', messages: {...}} | ||
*/ | ||
initialize(data) { | ||
this.data = data; | ||
FormatJSHelper.prototype = { | ||
return this; | ||
}, | ||
/** | ||
@@ -113,2 +116,2 @@ * Get the locale string | ||
module.exports = FormatJSHelper; | ||
module.exports = formatJSHelper; |
{ | ||
"name": "formatjs-helper", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "FormatJSHelper is a simple wrapper for your localization message data that makes working with data in the formats needed by FormatJS easy.", | ||
@@ -5,0 +5,0 @@ "main": "formatjs_helper.js", |
@@ -1,4 +0,6 @@ | ||
var FormatJSHelper = require('../formatjs_helper'); | ||
var formatJSHelper = require('../formatjs_helper'); | ||
describe('FormatJSHelper', function() { | ||
console.log('sup', formatJSHelper); | ||
describe('formatJSHelper', function() { | ||
var data; | ||
@@ -19,3 +21,3 @@ | ||
it('returns the locale in the data', function() { | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -28,3 +30,3 @@ expect(formatJSHelper.getLocale()).toBe('en-US'); | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -37,3 +39,3 @@ expect(formatJSHelper.getLocale()).toBe(''); | ||
it('returns only the language from a full locale string', function() { | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -46,3 +48,3 @@ expect(formatJSHelper.getLocaleLanguage()).toBe('en'); | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -55,3 +57,3 @@ expect(formatJSHelper.getLocaleLanguage()).toBe('en'); | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -64,3 +66,3 @@ expect(formatJSHelper.getLocaleLanguage()).toBe(''); | ||
it('returns the correct language string in a typical use case', function() { | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -73,3 +75,3 @@ expect(formatJSHelper.get('homeTemplate', 'title')).toBe('Home'); | ||
var value = 'imaval'; | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
var obj = data.messages; | ||
@@ -92,3 +94,3 @@ var args = [key]; | ||
it('returns the full intl data object', function() { | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -101,3 +103,3 @@ expect(formatJSHelper.getIntl()).toBe(data); | ||
it('returns the intl data under the intl key', function() { | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -110,3 +112,3 @@ expect(formatJSHelper.getData()).toEqual({intl: data}); | ||
it('returns the intl data under the intl key under the data key', function() { | ||
var formatJSHelper = new FormatJSHelper(data); | ||
formatJSHelper.initialize(data); | ||
@@ -113,0 +115,0 @@ expect(formatJSHelper.getOptions()).toEqual({ data: {intl: data}}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193
7999