@@ -51,23 +51,23 @@ test('elmish.mount app expect state to be Zero', function (t) {
51
51
} ) ;
52
52
53
53
54
- test ( 'elmish.attributes applies class HTML attribute to a node' , function ( t ) {
54
+ test ( 'elmish.add_attributes applies HTML claa attribute to node' , function ( t ) {
55
55
const root = document . getElementById ( id ) ;
56
56
let div = document . createElement ( 'div' ) ;
57
57
div . id = 'divid' ;
58
- div = elmish . attributes ( [ "class=apptastic" ] , div ) ;
58
+ div = elmish . add_attributes ( [ "class=apptastic" ] , div ) ;
59
59
root . appendChild ( div ) ;
60
60
// test the div has the desired class:
61
61
const nodes = document . getElementsByClassName ( 'apptastic' ) ;
62
62
t . equal ( nodes . length , 1 , "<div> has 'apptastic' class applied" ) ;
63
63
t . end ( ) ;
64
64
} ) ;
65
65
66
- test ( 'elmish.attributes applies id HTML attribute to a node' , function ( t ) {
66
+ test ( 'elmish.add_attributes applies id HTML attribute to a node' , function ( t ) {
67
67
const root = document . getElementById ( id ) ;
68
68
elmish . empty ( root ) ;
69
69
let el = document . createElement ( 'section' ) ;
70
- el = elmish . attributes ( [ "id=myid" ] , el ) ;
70
+ el = elmish . add_attributes ( [ "id=myid" ] , el ) ;
71
71
const text = 'hello world!'
72
72
var txt = document . createTextNode ( text ) ;
73
73
el . appendChild ( txt ) ;
@@ -77,13 +77,39 @@ test('elmish.attributes applies id HTML attribute to a node', function (t) {
77
77
t . end ( ) ;
78
78
} ) ;
79
79
80
- test ( 'test default branch of elmish.attributes (no effect)' , function ( t ) {
80
+ test ( 'elmish.add_attributes applies multiple attribute to node' , function ( t ) {
81
+ const root = document . getElementById ( id ) ;
82
+ elmish . empty ( root ) ;
83
+ let el = document . createElement ( 'span' ) ;
84
+ el = elmish . add_attributes ( [ "id=myid" , "class=totes mcawesome" ] , el ) ;
85
+ const text = 'hello world'
86
+ var txt = document . createTextNode ( text ) ;
87
+ el . appendChild ( txt ) ;
88
+ root . appendChild ( el ) ;
89
+ const actual = document . getElementById ( 'myid' ) . textContent ;
90
+ t . equal ( actual , text , "<section> has 'myid' id attribute" ) ;
91
+ t . equal ( el . className , 'totes mcawesome' , "CSS class applied: " , el . className ) ;
92
+ t . end ( ) ;
93
+ } ) ;
94
+
95
+ test ( 'test default branch of elmish.add_attributes (no effect)' , function ( t ) {
96
+ const root = document . getElementById ( id ) ;
97
+ let div = document . createElement ( 'div' ) ;
98
+ div . id = 'divid' ;
99
+ // "Clone" the div DOM node before invoking the elmish.attributes
100
+ const clone = div . cloneNode ( true ) ;
101
+ div = elmish . add_attributes ( [ "unrecognised_attribute=noise" ] , div ) ;
102
+ t . deepEqual ( div , clone , "<div> has not been altered" ) ;
103
+ t . end ( ) ;
104
+ } ) ;
105
+
106
+ test ( 'elmish.' , function ( t ) {
81
107
const root = document . getElementById ( id ) ;
82
108
let div = document . createElement ( 'div' ) ;
83
109
div . id = 'divid' ;
84
110
// "Clone" the div DOM node before invoking the elmish.attributes
85
111
const clone = div . cloneNode ( true ) ;
86
- div = elmish . attributes ( [ "unrecognised_attribute=noise" ] , div ) ;
112
+ div = elmish . add_attributes ( [ "unrecognised_attribute=noise" ] , div ) ;
87
113
t . deepEqual ( div , clone , "<div> has not been altered" ) ;
88
114
t . end ( ) ;
89
115
} ) ;
0 commit comments