|
@@ -14,52 +14,97 @@ describe( 'Locale', () => {
|
|
|
|
|
|
|
|
describe( 'constructor', () => {
|
|
describe( 'constructor', () => {
|
|
|
it( 'sets the #language', () => {
|
|
it( 'sets the #language', () => {
|
|
|
- const locale = new Locale( 'pl' );
|
|
|
|
|
|
|
+ const locale = new Locale( {
|
|
|
|
|
+ uiLanguage: 'pl'
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- expect( locale ).to.have.property( 'language', 'pl' );
|
|
|
|
|
|
|
+ expect( locale ).to.have.property( 'uiLanguage', 'pl' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'sets the #contentLanguage', () => {
|
|
it( 'sets the #contentLanguage', () => {
|
|
|
- const locale = new Locale( 'pl', 'en' );
|
|
|
|
|
|
|
+ const locale = new Locale( {
|
|
|
|
|
+ uiLanguage: 'pl',
|
|
|
|
|
+ contentLanguage: 'en'
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- expect( locale ).to.have.property( 'language', 'pl' );
|
|
|
|
|
|
|
+ expect( locale ).to.have.property( 'uiLanguage', 'pl' );
|
|
|
expect( locale ).to.have.property( 'contentLanguage', 'en' );
|
|
expect( locale ).to.have.property( 'contentLanguage', 'en' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'defaults #language to en', () => {
|
|
it( 'defaults #language to en', () => {
|
|
|
const locale = new Locale();
|
|
const locale = new Locale();
|
|
|
|
|
|
|
|
- expect( locale ).to.have.property( 'language', 'en' );
|
|
|
|
|
|
|
+ expect( locale ).to.have.property( 'uiLanguage', 'en' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'inherits the #contentLanguage from the #language (if not passed)', () => {
|
|
it( 'inherits the #contentLanguage from the #language (if not passed)', () => {
|
|
|
- const locale = new Locale( 'pl' );
|
|
|
|
|
|
|
+ const locale = new Locale( {
|
|
|
|
|
+ uiLanguage: 'pl'
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- expect( locale ).to.have.property( 'language', 'pl' );
|
|
|
|
|
|
|
+ expect( locale ).to.have.property( 'uiLanguage', 'pl' );
|
|
|
expect( locale ).to.have.property( 'contentLanguage', 'pl' );
|
|
expect( locale ).to.have.property( 'contentLanguage', 'pl' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'determines the #languageDirection', () => {
|
|
|
|
|
- expect( new Locale( 'pl' ) ).to.have.property( 'languageDirection', 'ltr' );
|
|
|
|
|
- expect( new Locale( 'en' ) ).to.have.property( 'languageDirection', 'ltr' );
|
|
|
|
|
|
|
+ it( 'determines the #uiLanguageDirection', () => {
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'pl'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'ltr' );
|
|
|
|
|
|
|
|
- expect( new Locale( 'ar' ) ).to.have.property( 'languageDirection', 'rtl' );
|
|
|
|
|
- expect( new Locale( 'fa' ) ).to.have.property( 'languageDirection', 'rtl' );
|
|
|
|
|
- expect( new Locale( 'he' ) ).to.have.property( 'languageDirection', 'rtl' );
|
|
|
|
|
- expect( new Locale( 'ku' ) ).to.have.property( 'languageDirection', 'rtl' );
|
|
|
|
|
- expect( new Locale( 'ug' ) ).to.have.property( 'languageDirection', 'rtl' );
|
|
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'en'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'ltr' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'ar'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'rtl' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'fa'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'rtl' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'he'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'rtl' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'ku'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'rtl' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'ug'
|
|
|
|
|
+ } ) ).to.have.property( 'uiLanguageDirection', 'rtl' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'determines the #contentLanguageDirection (not passed)', () => {
|
|
it( 'determines the #contentLanguageDirection (not passed)', () => {
|
|
|
- expect( new Locale( 'pl' ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
- expect( new Locale( 'en' ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
- expect( new Locale( 'ar' ) ).to.have.property( 'contentLanguageDirection', 'rtl' );
|
|
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'pl'
|
|
|
|
|
+ } ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'en'
|
|
|
|
|
+ } ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'ar'
|
|
|
|
|
+ } ) ).to.have.property( 'contentLanguageDirection', 'rtl' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'determines the #contentLanguageDirection (passed)', () => {
|
|
it( 'determines the #contentLanguageDirection (passed)', () => {
|
|
|
- expect( new Locale( 'pl', 'pl' ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
- expect( new Locale( 'en', 'ar' ) ).to.have.property( 'contentLanguageDirection', 'rtl' );
|
|
|
|
|
- expect( new Locale( 'ar', 'pl' ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'pl',
|
|
|
|
|
+ contentLanguage: 'pl'
|
|
|
|
|
+ } ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'en',
|
|
|
|
|
+ contentLanguage: 'ar'
|
|
|
|
|
+ } ) ).to.have.property( 'contentLanguageDirection', 'rtl' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( new Locale( {
|
|
|
|
|
+ uiLanguage: 'ar',
|
|
|
|
|
+ contentLanguage: 'pl'
|
|
|
|
|
+ } ) ).to.have.property( 'contentLanguageDirection', 'ltr' );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|