@@ -25,6 +25,7 @@ module('Integration | Component | hds/tag/index', function (hooks) {
25
25
await render ( hbs `<Hds::Tag @text="My tag" />` ) ;
26
26
assert . dom ( 'button.hds-tag__dismiss' ) . doesNotExist ( ) ;
27
27
} ) ;
28
+
28
29
test ( 'it should render the "dismiss" button if a callback function is passed to the @onDismiss argument' , async function ( assert ) {
29
30
this . set ( 'NOOP' , ( ) => { } ) ;
30
31
await render ( hbs `<Hds::Tag @text="My tag" @onDismiss={{this.NOOP}} />` ) ;
@@ -44,6 +45,7 @@ module('Integration | Component | hds/tag/index', function (hooks) {
44
45
. dom ( 'button.hds-tag__dismiss' )
45
46
. hasAttribute ( 'aria-label' , 'Please dismiss My tag' ) ;
46
47
} ) ;
48
+
47
49
// COLOR
48
50
49
51
test ( 'it should render the primary color as the default if no @color prop is declared when the text is a link' , async function ( assert ) {
@@ -52,12 +54,14 @@ module('Integration | Component | hds/tag/index', function (hooks) {
52
54
) ;
53
55
assert . dom ( '#test-link-tag' ) . hasClass ( 'hds-tag--color-primary' ) ;
54
56
} ) ;
57
+
55
58
test ( 'it should render the correct CSS color class if the @color prop is declared when the text is a link' , async function ( assert ) {
56
59
await render (
57
60
hbs `<Hds::Tag @text="My text tag" @href="/" @color="secondary" id="test-link-tag"/>`
58
61
) ;
59
62
assert . dom ( '#test-link-tag' ) . hasClass ( 'hds-tag--color-secondary' ) ;
60
63
} ) ;
64
+
61
65
test ( 'it should throw an assertion if an incorrect value for @color is provided when the text is a link' , async function ( assert ) {
62
66
const errorMessage =
63
67
'@color for "Hds::Tag" must be one of the following: primary, secondary; received: foo' ;
@@ -70,6 +74,7 @@ module('Integration | Component | hds/tag/index', function (hooks) {
70
74
throw new Error ( errorMessage ) ;
71
75
} ) ;
72
76
} ) ;
77
+
73
78
test ( 'it should throw an assertion if @color is provided without @href or @route' , async function ( assert ) {
74
79
const errorMessage =
75
80
'@color can only be applied to "Hds::Tag" along with either @href or @route' ;
@@ -82,4 +87,22 @@ module('Integration | Component | hds/tag/index', function (hooks) {
82
87
throw new Error ( errorMessage ) ;
83
88
} ) ;
84
89
} ) ;
90
+
91
+ // OVERFLOW
92
+
93
+ test ( 'it should not render a tooltip if the text does not overflow' , async function ( assert ) {
94
+ await render ( hbs `
95
+ <Hds::Tag @text="My text tag" id="test-tag"/>
96
+ ` ) ;
97
+ assert . dom ( '.hds-tooltip-button' ) . doesNotExist ( ) ;
98
+ } ) ;
99
+
100
+ test ( 'it should render a tooltip if the text overflows' , async function ( assert ) {
101
+ await render ( hbs `
102
+ <div style="width: 50px;">
103
+ <Hds::Tag @text="This is a very long text that should go on multiple lines" id="test-tag"/>
104
+ </div>
105
+ ` ) ;
106
+ assert . dom ( '.hds-tooltip-button' ) . exists ( ) ;
107
+ } ) ;
85
108
} ) ;
0 commit comments