Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 85c4e0f

Browse files
committed
Add spec for text-direction component
1 parent e24bfb4 commit 85c4e0f

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/common/cd-text-direction-wrapper.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
<script>
88
export default {
9-
props: ['direction'],
9+
name: 'TextDirectionWrapper',
10+
props: {
11+
direction: String,
12+
},
1013
computed: {
1114
textDirection() {
1215
if (this.direction) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
});

0 commit comments

Comments
 (0)