This repository was archived by the owner on Dec 14, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
<script >
8
8
export default {
9
- props: [' direction' ],
9
+ name: ' TextDirectionWrapper' ,
10
+ props: {
11
+ direction: String ,
12
+ },
10
13
computed: {
11
14
textDirection () {
12
15
if (this .direction ) {
Original file line number Diff line number Diff line change
1
+ import vueUnitHelper from 'vue-unit-helper' ;
2
+ import TextDirectionWrapper from '@/common/cd-text-direction-wrapper' ;
3
+
4
+ describe . only ( 'Text Direction Wrapper' , ( ) => {
5
+
6
+ describe ( 'computed.textDirection' , ( ) => {
7
+ context ( 'when chosen language specifies a direction' , ( ) => {
8
+ it ( 'returns that value' , ( ) => {
9
+ const vm = vueUnitHelper ( TextDirectionWrapper ) ;
10
+ vm . $store = {
11
+ getters : {
12
+ get chosenLanguageConfig ( ) { return { dir : 'test' } } ,
13
+ } ,
14
+ } ;
15
+ expect ( vm . textDirection ) . to . eql ( 'test' ) ;
16
+ } ) ;
17
+ } ) ;
18
+
19
+ context ( 'when chosen language doesn\'t specify a direction' , ( ) => {
20
+ it ( 'returns default' , ( ) => {
21
+ const vm = vueUnitHelper ( TextDirectionWrapper ) ;
22
+ vm . $store = {
23
+ getters : {
24
+ get chosenLanguageConfig ( ) { return { } } ,
25
+ } ,
26
+ } ;
27
+ expect ( vm . textDirection ) . to . eql ( 'ltr' ) ;
28
+ } ) ;
29
+ } ) ;
30
+
31
+ context ( 'when initialised with a prop' , ( ) => {
32
+ it ( 'overrides the chosen language direction' , ( ) => {
33
+ const vm = vueUnitHelper ( TextDirectionWrapper ) ;
34
+ vm . direction = 'down'
35
+ vm . $store = {
36
+ getters : {
37
+ get chosenLanguageConfig ( ) { return { dir : 'test' } } ,
38
+ } ,
39
+ } ;
40
+ expect ( vm . textDirection ) . to . eql ( 'down' ) ;
41
+ } ) ;
42
+ } ) ;
43
+ } ) ;
44
+
45
+ } ) ;
You can’t perform that action at this time.
0 commit comments