import test from 'tape' import nlp from '../_lib.js' const here = '[one/html] ' test('html-match', function (t) { let doc = nlp(`match one two. one match two. one two match.`) let html = doc.html({ i: 'match' }) t.equal(html, `match one two. one match two. one two match.`, here + 'html tag') doc = nlp(`match one two. one match two.`) html = doc.html({ '.foo': 'match' }) t.equal(html, `match one two. one match two.`, here + 'html class') doc = nlp(`one match match two.`) html = doc.html({ '#foo': 'match+' }) t.equal(html, `one match match two.`, here + 'html id') doc = nlp(`one match two.`) html = doc.html({ '.red': 'match+', '.blue': doc.match('two') }) t.equal(html, `one match two.`, here + 'html two classes') doc = nlp(`if i can recall, my grey dog loves pizza crusts (they are really good).`) html = doc.html({ '.red': 'my grey dog', '.blue': doc.match('loves') }) t.equal( html, `if i can recall, my grey dog loves pizza crusts (they are really good).`, here + 'html pre test' ) t.end() }) test('html-nest', function (t) { const doc = nlp(`one match two.`) let html = doc.html({ i: 'match', b: 'one match two', }) t.equal(html, `one match two.`, here + 'easy nest') html = doc.html({ b: 'match two', i: 'match', }) t.equal(html, `one match two.`, here + 'hard nest') // html = doc.html({ // i: 'match', // b: 'match two', // }) // t.equal(html, `one match two.`, here + 'harder nest') t.end() }) test('html-implicit', function (t) { const doc = nlp(`he's cool`) const out = doc.html({ '.foo': '#Verb' }) t.equal(out, `he's cool`, here + 'implict') t.end() })