Skip to content

Commit 4f7356d

Browse files
committed
Merge branch 'feat/json-to-go' into chore/all-my-stuffs
# Conflicts: # src/tools/index.ts
2 parents 4cdcbaf + 47888b5 commit 4f7356d

File tree

6 files changed

+605
-0
lines changed

6 files changed

+605
-0
lines changed

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { tool as heicConverter } from './heic-converter';
5555
import { tool as icalParser } from './ical-parser';
5656
import { tool as icalGenerator } from './ical-generator';
5757
import { tool as imageToCss } from './image-to-css';
58+
import { tool as jsonToGo } from './json-to-go';
5859
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
5960
import { tool as numeronymGenerator } from './numeronym-generator';
6061
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -183,6 +184,7 @@ export const toolsByCategory: ToolCategory[] = [
183184
currencyConverter,
184185
hddCalculator,
185186
jsonToCsharp,
187+
jsonToGo,
186188
],
187189
},
188190
{

src/tools/json-to-go/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Braces } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'JSON to Go',
6+
path: '/json-to-go',
7+
description: 'Convert JSON to Go struct',
8+
keywords: ['json', 'parse', 'go', 'convert', 'transform'],
9+
component: () => import('./json-to-go.vue'),
10+
icon: Braces,
11+
createdAt: new Date('2024-04-02'),
12+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { jsonToGo } from './json-to-go.service';
3+
import testCases from './json-to-go.test.data.json';
4+
5+
describe('json-to-go', () => {
6+
describe('jsonToGo', () => {
7+
for (const includeExampleData of [true, false]) {
8+
it(`must return correct results (includeExampleData = ${includeExampleData})`, () => {
9+
for (const testCase of testCases) {
10+
const got = jsonToGo(testCase.input, '', false, includeExampleData);
11+
const expected = includeExampleData
12+
? testCase.expectedWithExample
13+
: testCase.expected;
14+
15+
expect(got.go).to.equal(expected);
16+
}
17+
});
18+
}
19+
});
20+
});

0 commit comments

Comments
 (0)