Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from drewfish/testing
converted tests to use mocha & chai
- Loading branch information
Showing
5 changed files
with
86 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/formatjs/packages/intl-messageformat/tests/message.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/*jshint node:true */ | ||
/*global describe,it */ | ||
'use strict'; | ||
|
||
|
||
var expect = require('chai').expect, | ||
MessageFormatter = require('../lib/message.js'); | ||
|
||
|
||
describe('message creation', function () { | ||
|
||
it('simple string formatting', function () { | ||
var msg, m; | ||
msg = new MessageFormatter(null, 'My name is ${first} {last}.'); | ||
m = msg.format({ | ||
first: 'Anthony', | ||
last: 'Pipkin' | ||
}); | ||
expect(m).to.equal('My name is Anthony Pipkin.'); | ||
}); | ||
|
||
|
||
it ('complex object formatter', function () { | ||
var msg, m; | ||
msg = new MessageFormatter(null, ['Some text before ', { | ||
type: 'plural', | ||
valueName: 'numPeople', | ||
offset: 1, | ||
options: { | ||
one: 'Some message ${ph} with ${#} value', | ||
|
||
few: ['Optional prefix text for |few| ', { | ||
type: 'select', | ||
valueName: 'gender', | ||
options: { | ||
male: 'Text for male option with \' single quotes', | ||
female: 'Text for female option with {}', | ||
other: 'Text for default' | ||
} | ||
}, ' optional postfix text'], | ||
|
||
other: 'Some messages for the default', | ||
|
||
'1': ['Optional prefix text ', { | ||
type: 'select', | ||
valueName: 'gender', | ||
options: { | ||
male: 'Text for male option with \' single quotes', | ||
female: 'Text for female option with {}', | ||
other: 'Text for default' | ||
} | ||
}, ' optional postfix text'], | ||
} | ||
}, ' and text after']); | ||
m = msg.format({ | ||
numPeople: 4, | ||
ph: 'whatever', | ||
gender: 'male' | ||
}); | ||
expect(m).to.equal("Some text before Optional prefix text for |few| Text for male option with ' single quotes optional postfix text and text after"); | ||
}); | ||
|
||
|
||
it('Simple string formatter using a custom formatter for a token', function () { | ||
var msg, m; | ||
msg = new MessageFormatter(null, 'Test formatter d: ${num:d}', { | ||
d: function (locale, val) { | ||
return +val; | ||
} | ||
}); | ||
m = msg.format({ | ||
num: '010' | ||
}); | ||
expect(m).to.equal('Test formatter d: 10'); | ||
}); | ||
|
||
}); | ||
|
||
|
75 changes: 0 additions & 75 deletions
75
packages/formatjs/packages/intl-messageformat/tests/test.js
This file was deleted.
Oops, something went wrong.