dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
42 lines
1023 B
JavaScript
42 lines
1023 B
JavaScript
import { describe, it, expect } from 'vitest';
|
|
|
|
import { findAll } from './find-all';
|
|
|
|
const testTree = {
|
|
type: 'root',
|
|
children: [
|
|
{
|
|
type: 'heading',
|
|
depth: 1,
|
|
children: [{ type: 'text', value: 'test', testId: 1 }]
|
|
},
|
|
{
|
|
type: 'paragraph',
|
|
children: [{ type: 'text', value: 'different', testId: 2 }]
|
|
},
|
|
{
|
|
type: 'heading',
|
|
depth: 2,
|
|
children: [{ type: 'text', value: 'test', testId: 3 }]
|
|
},
|
|
{
|
|
type: 'heading',
|
|
depth: 1,
|
|
children: [{ type: 'text', value: 'test', testId: 4 }]
|
|
}
|
|
]
|
|
};
|
|
|
|
describe('findAll', () => {
|
|
it('should return an array', () => {
|
|
expect(findAll(testTree, () => false)).toEqual([]);
|
|
});
|
|
it('should return an array of nodes that match the test', () => {
|
|
expect(findAll(testTree, { type: 'text', value: 'test' })).toEqual([
|
|
{ type: 'text', value: 'test', testId: 1 },
|
|
{ type: 'text', value: 'test', testId: 3 },
|
|
{ type: 'text', value: 'test', testId: 4 }
|
|
]);
|
|
});
|
|
});
|