|
1 | 1 | import assert from 'node:assert/strict'
|
2 | 2 | import test from 'node:test'
|
3 | 3 | import {hasProperty} from './index.js'
|
4 |
| -import * as mod from './index.js' |
5 | 4 |
|
6 |
| -test('hasProperty', () => { |
7 |
| - assert.deepEqual( |
8 |
| - Object.keys(mod).sort(), |
9 |
| - ['hasProperty'], |
10 |
| - 'should expose the public api' |
11 |
| - ) |
| 5 | +test('hasProperty', async function (t) { |
| 6 | + await t.test('should expose the public api', async function () { |
| 7 | + assert.deepEqual(Object.keys(await import('./index.js')).sort(), [ |
| 8 | + 'hasProperty' |
| 9 | + ]) |
| 10 | + }) |
12 | 11 |
|
13 |
| - assert.equal( |
14 |
| - hasProperty(null, 'alpha'), |
15 |
| - false, |
16 |
| - 'should return `false` without node' |
17 |
| - ) |
| 12 | + await t.test('should return `false` without node', async function () { |
| 13 | + assert.equal(hasProperty(null, 'alpha'), false) |
| 14 | + }) |
18 | 15 |
|
19 |
| - assert.equal( |
20 |
| - hasProperty({type: 'text', value: 'alpha'}, 'bravo'), |
21 |
| - false, |
22 |
| - 'should return `false` without `element`' |
23 |
| - ) |
| 16 | + await t.test('should return `false` without `element`', async function () { |
| 17 | + assert.equal(hasProperty({type: 'text', value: 'alpha'}, 'bravo'), false) |
| 18 | + }) |
24 | 19 |
|
25 |
| - assert.equal( |
26 |
| - hasProperty({type: 'element'}, 'charlie'), |
27 |
| - false, |
28 |
| - 'should return `false` without properties' |
29 |
| - ) |
| 20 | + await t.test('should return `false` without properties', async function () { |
| 21 | + assert.equal(hasProperty({type: 'element'}, 'charlie'), false) |
| 22 | + }) |
30 | 23 |
|
31 |
| - assert.equal( |
32 |
| - hasProperty({type: 'element', properties: {}}, 'toString'), |
33 |
| - false, |
34 |
| - 'should return `false` for prototypal properties' |
| 24 | + await t.test( |
| 25 | + 'should return `false` for prototypal properties', |
| 26 | + async function () { |
| 27 | + assert.equal( |
| 28 | + hasProperty({type: 'element', properties: {}}, 'toString'), |
| 29 | + false |
| 30 | + ) |
| 31 | + } |
35 | 32 | )
|
36 | 33 |
|
37 |
| - assert.equal( |
38 |
| - hasProperty( |
39 |
| - { |
40 |
| - type: 'element', |
41 |
| - properties: {id: 'delta'} |
42 |
| - }, |
43 |
| - 'echo' |
44 |
| - ), |
45 |
| - false, |
46 |
| - 'should return `false` if the property does not exist' |
| 34 | + await t.test( |
| 35 | + 'should return `false` if the property does not exist', |
| 36 | + async function () { |
| 37 | + assert.equal( |
| 38 | + hasProperty( |
| 39 | + { |
| 40 | + type: 'element', |
| 41 | + properties: {id: 'delta'} |
| 42 | + }, |
| 43 | + 'echo' |
| 44 | + ), |
| 45 | + false |
| 46 | + ) |
| 47 | + } |
47 | 48 | )
|
48 | 49 |
|
49 |
| - assert.equal( |
50 |
| - // @ts-expect-error runtime. |
51 |
| - hasProperty({type: 'element', properties: {id: 'delta'}}), |
52 |
| - false, |
53 |
| - 'should return `false` if without `name`' |
54 |
| - ) |
| 50 | + await t.test('should return `false` if without `name`', async function () { |
| 51 | + assert.equal( |
| 52 | + // @ts-expect-error: check how a missing name is handled. |
| 53 | + hasProperty({type: 'element', properties: {id: 'delta'}}), |
| 54 | + false |
| 55 | + ) |
| 56 | + }) |
55 | 57 |
|
56 |
| - assert.equal( |
57 |
| - hasProperty( |
58 |
| - { |
59 |
| - type: 'element', |
60 |
| - properties: {id: 'delta'} |
61 |
| - }, |
62 |
| - 'id' |
63 |
| - ), |
64 |
| - true, |
65 |
| - 'should return `true` if the property does exist' |
| 58 | + await t.test( |
| 59 | + 'should return `true` if the property does exist', |
| 60 | + async function () { |
| 61 | + assert.equal( |
| 62 | + hasProperty( |
| 63 | + { |
| 64 | + type: 'element', |
| 65 | + properties: {id: 'delta'} |
| 66 | + }, |
| 67 | + 'id' |
| 68 | + ), |
| 69 | + true |
| 70 | + ) |
| 71 | + } |
66 | 72 | )
|
67 | 73 | })
|
0 commit comments