Permalink
Browse files

failing set attribute tests for selectAll

  • Loading branch information...
1 parent c1477d7 commit 28bebeef348da674de265380bc8e66407ac50e0e @substack committed Sep 5, 2013
Showing with 42 additions and 0 deletions.
  1. +2 −0 test/set_attrs.html
  2. +40 −0 test/set_attrs.js
View
@@ -0,0 +1,2 @@
+<div class="a"><input type="text" value="xyz"></div>
+<div class="a"><input type="text" value="ghi"></div>
View
@@ -0,0 +1,40 @@
+var trumpet = require('../');
+var fs = require('fs');
+var test = require('tape');
+var concat = require('concat-stream');
+
+test('set attributes', function (t) {
+ t.plan(1);
+
+ var tr = trumpet();
+ tr.selectAll('input[type=text]', function (elem) {
+ elem.setAttribute('value', elem.attributes.VALUE.toUpperCase());
+ });
+
+ tr.pipe(concat(function (src) {
+ t.equal(
+ String(src),
+ '<div class="a"><input type="text" value="XYZ"></div>\n'
+ + '<div class="a"><input type="text" value="GHI"></div>\n'
+ );
+ }));
+ fs.createReadStream(__dirname + '/set_attrs.html').pipe(tr);
+});
+
+test('create attributes', function (t) {
+ t.plan(1);
+
+ var tr = trumpet();
+ tr.selectAll('input[type=text]', function (elem) {
+ elem.setAttribute('beep', 'boop');
+ });
+
+ tr.pipe(concat(function (src) {
+ t.equal(
+ String(src),
+ '<div class="a"><input type="text" value="xyz" beep="boop"></div>\n'
+ + '<div class="a"><input type="text" value="ghi" beep="boop"></div>\n'
+ );
+ }));
+ fs.createReadStream(__dirname + '/set_attrs.html').pipe(tr);
+});

0 comments on commit 28bebee

Please sign in to comment.