2021-05-08 11:32:41 -07:00
// Topics
2017-09-20 16:04:46 -07:00
// * modules
// * strings
// Pig Latin
2021-05-08 11:27:13 -07:00
// Pig Latin is a made-up children's language that's intended to be confusing. It obeys a few simple rules (below) but when it's spoken quickly it's really difficult for non-children (and non-native speakers) to understand.
2017-09-20 16:04:46 -07:00
// Rule 1: If a word begins with a vowel sound, add an "ay" sound to the end of the word.
2021-05-08 11:27:13 -07:00
// Rule 2: If a word begins with a consonant sound, move it to the end of the word, and then add an "ay" sound to the end of the word.
2017-09-20 16:04:46 -07:00
// (There are a few more rules for edge cases, and there are regional variants too, but that should be enough to understand the tests.)
// See https://en.wikipedia.org/wiki/Pig_Latin for more details.
2018-08-07 03:23:28 -07:00
const pigLatin = require ( "./pigLatin.js" ) ;
2017-09-20 16:04:46 -07:00
2021-05-08 11:27:13 -07:00
describe ( '#translate' , function ( ) {
it ( 'translates a word beginning with a vowel' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "apple" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( 'appleay' ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'translates a word beginning with a consonant' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "banana" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( "ananabay" ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'translates a word beginning with two consonants' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "cherry" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( 'errychay' ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'translates two words' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "eat pie" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( 'eatay iepay' ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'translates a word beginning with three consonants' , function ( ) {
expect ( pigLatin . translate ( "three" ) ) . toEqual ( "eethray" ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'counts "sch" as a single phoneme' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "school" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( "oolschay" ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'counts "qu" as a single phoneme' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "quiet" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( "ietquay" ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'counts "qu" as a consonant even when its preceded by a consonant' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "square" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( "aresquay" ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2021-05-08 11:27:13 -07:00
xit ( 'translates many words' , function ( ) {
2017-09-20 16:04:46 -07:00
s = pigLatin . translate ( "the quick brown fox" ) ;
2021-05-08 11:27:13 -07:00
expect ( s ) . toEqual ( "ethay ickquay ownbray oxfay" ) ;
2017-09-20 16:04:46 -07:00
} ) ;
2018-08-07 03:23:28 -07:00
} ) ;