-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
3,417 additions
and
3,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,40 @@ | ||
import test from 'tape' | ||
import assert from 'node:assert/strict' | ||
import test from 'node:test' | ||
import {u} from 'unist-builder' | ||
import {fromString} from './index.js' | ||
|
||
test('hast-util-from-string', (t) => { | ||
t.deepEqual( | ||
// @ts-expect-error: `value` missing. | ||
fromString(u('text'), 'foo'), | ||
u('text', 'foo'), | ||
'should set text nodes' | ||
) | ||
test('hast-util-from-string', async function (t) { | ||
await t.test('should set text nodes', async function () { | ||
assert.deepEqual( | ||
// @ts-expect-error: `value` missing. | ||
fromString(u('text'), 'foo'), | ||
u('text', 'foo') | ||
) | ||
}) | ||
|
||
t.deepEqual( | ||
// @ts-expect-error: `value` missing. | ||
fromString(u('text')), | ||
u('text', ''), | ||
'should reset text nodes (1)' | ||
) | ||
await t.test('should reset text nodes (1)', async function () { | ||
assert.deepEqual( | ||
// @ts-expect-error: `value` missing. | ||
fromString(u('text')), | ||
u('text', '') | ||
) | ||
}) | ||
|
||
t.deepEqual( | ||
fromString(u('text', 'foo')), | ||
u('text', ''), | ||
'should reset text nodes (2)' | ||
) | ||
await t.test('should reset text nodes (2)', async function () { | ||
assert.deepEqual(fromString(u('text', 'foo')), u('text', '')) | ||
}) | ||
|
||
t.deepEqual( | ||
fromString(u('element', {tagName: 'p', properties: {}}, []), 'foo'), | ||
u('element', {tagName: 'p', properties: {}}, [u('text', 'foo')]), | ||
'should set parent nodes' | ||
) | ||
|
||
t.deepEqual( | ||
fromString(u('element', {tagName: 'p', properties: {}}, [])), | ||
u('element', {tagName: 'p', properties: {}}, []), | ||
'should reset parent nodes (1)' | ||
) | ||
|
||
t.deepEqual( | ||
fromString( | ||
await t.test('should set parent nodes', async function () { | ||
assert.deepEqual( | ||
fromString(u('element', {tagName: 'p', properties: {}}, []), 'foo'), | ||
u('element', {tagName: 'p', properties: {}}, [u('text', 'foo')]) | ||
), | ||
u('element', {tagName: 'p', properties: {}}, []), | ||
'should reset parent nodes (2)' | ||
) | ||
) | ||
}) | ||
|
||
t.end() | ||
await t.test('should reset parent nodes', async function () { | ||
assert.deepEqual( | ||
fromString(u('element', {tagName: 'p', properties: {}}, [])), | ||
u('element', {tagName: 'p', properties: {}}, []) | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,85 @@ | ||
import test from 'tape' | ||
import assert from 'node:assert/strict' | ||
import test from 'node:test' | ||
import {u} from 'unist-builder' | ||
import {h} from 'hastscript' | ||
import {isBodyOkLink} from './index.js' | ||
|
||
test('isBodyOkLink', (t) => { | ||
t.equal( | ||
isBodyOkLink(h('link', {itemProp: 'foo'})), | ||
true, | ||
'yes - for `link`s with `itemProp`' | ||
) | ||
test('isBodyOkLink', async function (t) { | ||
await t.test('should be yes for `link`s with `itemProp`', async function () { | ||
assert.equal(isBodyOkLink(h('link', {itemProp: 'foo'})), true) | ||
}) | ||
|
||
t.equal( | ||
isBodyOkLink(h('link', {rel: ['prefetch'], href: '//example.com'})), | ||
true, | ||
'yes - for `link`s with `rel[prefetch]`' | ||
await t.test( | ||
'should be yes for `link`s with `rel[prefetch]`', | ||
async function () { | ||
assert.equal( | ||
isBodyOkLink(h('link', {rel: ['prefetch'], href: '//example.com'})), | ||
true | ||
) | ||
} | ||
) | ||
|
||
t.equal( | ||
isBodyOkLink(h('link', {rel: ['stylesheet'], href: 'index.css'})), | ||
true, | ||
'yes - for `link`s with `rel[stylesheet]`' | ||
await t.test( | ||
'should be yes for `link`s with `rel[stylesheet]`', | ||
async function () { | ||
assert.equal( | ||
isBodyOkLink(h('link', {rel: ['stylesheet'], href: 'index.css'})), | ||
true | ||
) | ||
} | ||
) | ||
|
||
t.equal( | ||
isBodyOkLink(h('link', {rel: ['pingback'], href: '//example.com'})), | ||
true, | ||
'yes - for `link`s with `rel[pingback]`' | ||
await t.test( | ||
'should be yes for `link`s with `rel[pingback]`', | ||
async function () { | ||
assert.equal( | ||
isBodyOkLink(h('link', {rel: ['pingback'], href: '//example.com'})), | ||
true | ||
) | ||
} | ||
) | ||
|
||
t.equal( | ||
isBodyOkLink(h('link', {rel: ['author'], href: 'index.css'})), | ||
false, | ||
'no - for `link`s with other rel’s' | ||
) | ||
await t.test('should be no for `link`s with other rel’s', async function () { | ||
assert.equal( | ||
isBodyOkLink(h('link', {rel: ['author'], href: 'index.css'})), | ||
false | ||
) | ||
}) | ||
|
||
t.equal( | ||
isBodyOkLink(h('link', {rel: ['stylesheet', 'author'], href: 'index.css'})), | ||
false, | ||
'no - for `link`s with combined rel’s' | ||
await t.test( | ||
'should be no for `link`s with combined rel’s', | ||
async function () { | ||
assert.equal( | ||
isBodyOkLink( | ||
h('link', {rel: ['stylesheet', 'author'], href: 'index.css'}) | ||
), | ||
false | ||
) | ||
} | ||
) | ||
|
||
t.equal( | ||
isBodyOkLink(h('link')), | ||
false, | ||
'no - for `link`s without `rel` or `itemProp`' | ||
await t.test( | ||
'should be no for `link`s without `rel` or `itemProp`', | ||
async function () { | ||
assert.equal(isBodyOkLink(h('link')), false) | ||
} | ||
) | ||
|
||
t.equal( | ||
isBodyOkLink(u('element', {tagName: 'link', properties: {}}, [])), | ||
false, | ||
'no - for `link`s without `rel` or `itemProp` (2)' | ||
await t.test( | ||
'should be no for `link`s without `rel` or `itemProp` (2)', | ||
async function () { | ||
assert.equal( | ||
isBodyOkLink(u('element', {tagName: 'link', properties: {}}, [])), | ||
false | ||
) | ||
} | ||
) | ||
|
||
t.equal(isBodyOkLink(h('p')), false, 'no - for non-links') | ||
await t.test('should be no for non-links', async function () { | ||
assert.equal(isBodyOkLink(h('p')), false) | ||
}) | ||
|
||
t.equal(isBodyOkLink(u('text', 'foo')), false, 'no - for non-elements') | ||
t.end() | ||
await t.test('should be no for non-elements', async function () { | ||
assert.equal(isBodyOkLink(u('text', 'foo')), false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,44 @@ | ||
import test from 'tape' | ||
import assert from 'node:assert/strict' | ||
import test from 'node:test' | ||
import {u} from 'unist-builder' | ||
import {h} from 'hastscript' | ||
import {isConditionalComment} from './index.js' | ||
|
||
test('hast-util-is-conditional-comment', (t) => { | ||
const fixtures = [ | ||
'[if IE]>…<![endif]', | ||
'[if IE 6]>…<![endif]', | ||
'[if IE 7]>…<![endif]', | ||
'[if IE 8]>…<![endif]', | ||
'[if IE 9]>…<![endif]', | ||
'[if gte IE 8]>…<![endif]', | ||
'[if lt IE 9]>…<![endif]', | ||
'[if lte IE 7]>…<![endif]', | ||
'[if gt IE 6]>…<![endif]', | ||
'[if !IE]>', | ||
'<![endif]' | ||
] | ||
let index = -1 | ||
test('hast-util-is-conditional-comment', async function (t) { | ||
await t.test('should detect a bunch of comments', async function () { | ||
const fixtures = [ | ||
'[if IE]>…<![endif]', | ||
'[if IE 6]>…<![endif]', | ||
'[if IE 7]>…<![endif]', | ||
'[if IE 8]>…<![endif]', | ||
'[if IE 9]>…<![endif]', | ||
'[if gte IE 8]>…<![endif]', | ||
'[if lt IE 9]>…<![endif]', | ||
'[if lte IE 7]>…<![endif]', | ||
'[if gt IE 6]>…<![endif]', | ||
'[if !IE]>', | ||
'<![endif]' | ||
] | ||
let index = -1 | ||
|
||
while (++index < fixtures.length) { | ||
const d = fixtures[index] | ||
t.equal( | ||
isConditionalComment(u('comment', d)), | ||
true, | ||
'yes - <!--' + d + '-->' | ||
while (++index < fixtures.length) { | ||
assert.equal(isConditionalComment(u('comment', fixtures[index])), true) | ||
} | ||
}) | ||
|
||
await t.test('should be no for other comments', async function () { | ||
assert.equal( | ||
// @ts-expect-error: incorrect node. | ||
isConditionalComment(u('comments', 'foo')), | ||
false | ||
) | ||
} | ||
}) | ||
|
||
t.equal( | ||
// @ts-expect-error: incorrect node. | ||
isConditionalComment(u('comments', 'foo')), | ||
false, | ||
'no - for other comments' | ||
) | ||
t.equal(isConditionalComment(h('div')), false, 'no - for elements') | ||
t.equal(isConditionalComment(u('text', 'foo')), false, 'no - for texts') | ||
await t.test('should be no for elements', async function () { | ||
assert.equal(isConditionalComment(h('div')), false) | ||
}) | ||
|
||
t.end() | ||
await t.test('should be no for texts', async function () { | ||
assert.equal(isConditionalComment(u('text', 'foo')), false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.