1 | #!/usr/bin/env node
|
2 | import assert from 'node:assert';
|
3 | import {readFileSync} from 'node:fs';
|
4 |
|
5 | import {OUTPUT_INDEX_FILE, HugoIndexer} from './index.js';
|
6 |
|
7 | const index = new HugoIndexer();
|
8 | index._setOutput(OUTPUT_INDEX_FILE);
|
9 | index.createIndex();
|
10 |
|
11 | const expected = {
|
12 | ru: [
|
13 | {
|
14 | uri: '/posts/post-sub01',
|
15 | title: 'Test post 01 Ru',
|
16 | content: '\nTest post',
|
17 | tags: [],
|
18 | lang: 'ru',
|
19 | },
|
20 | ],
|
21 | en: [
|
22 | {
|
23 | uri: '/posts/post-sub01',
|
24 | title: 'Test post 01 Eng',
|
25 | content: '\nTest post',
|
26 | tags: [],
|
27 | lang: 'en',
|
28 | },
|
29 | ],
|
30 | };
|
31 |
|
32 | setTimeout(() => {
|
33 | const data = readFileSync(OUTPUT_INDEX_FILE);
|
34 | const fileData = JSON.parse(data);
|
35 | assert.equal(JSON.stringify(fileData), JSON.stringify(expected));
|
36 | }, 2000);
|
37 |
|