Skip to content

Commit

Permalink
Update npm
Browse files Browse the repository at this point in the history
```
./transformers/js-dvhcvn.sh
( cd transformers/js-dvhcvn && npm publish )
```
  • Loading branch information
daohoangson committed Nov 21, 2024
1 parent c8d2a6b commit 8b965ea
Show file tree
Hide file tree
Showing 7 changed files with 2,673 additions and 1,832 deletions.
18 changes: 9 additions & 9 deletions transformers/js-dvhcvn/bin/generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("generate", () => {
level2s: [],
});
expect(written.trim()).toEqual(
"new Level1('01', 'Thành phố Hà Nội', Type.tptw, [\n]),"
"new Level1('01', 'Thành phố Hà Nội', Type.tptw, [\n]),",
);
});

Expand All @@ -46,7 +46,7 @@ describe("generate", () => {
level3s: [],
});
expect(written.trim()).toEqual(
"new Level2(0, '001', 'Quận Ba Đình', Type.quan, [\n]),"
"new Level2(0, '001', 'Quận Ba Đình', Type.quan, [\n]),",
);
});

Expand All @@ -57,7 +57,7 @@ describe("generate", () => {
type: "Phường",
});
expect(written.trim()).toEqual(
"new Level3(0, 0, '00001', 'Phường Phúc Xá', Type.phuong),"
"new Level3(0, 0, '00001', 'Phường Phúc Xá', Type.phuong),",
);
});

Expand Down Expand Up @@ -85,14 +85,14 @@ describe("generate", () => {
],
},
],
})
}),
);

main(["/path/to/file.json"]);

expect(mocks.readFileSync).toHaveBeenCalledWith(
"/path/to/file.json",
expect.anything()
expect.anything(),
);

expect(written).toEqual(
Expand All @@ -105,7 +105,7 @@ describe("generate", () => {
"]),\n" +
"];\n" +
"\n" +
'export const parents: Record<string,string> = {"001":"01","00001":"001"};'
'export const parents: Record<string,string> = {"001":"01","00001":"001"};',
);
});

Expand All @@ -117,7 +117,7 @@ describe("generate", () => {
level2s: [],
});
expect(written.trim()).toEqual(
"new Level1('foo', \"Tỉnh Foo's\", Type.tinh, [\n]),"
"new Level1('foo', \"Tỉnh Foo's\", Type.tinh, [\n]),",
);
});

Expand All @@ -129,7 +129,7 @@ describe("generate", () => {
level2s: [],
});
expect(written.trim()).toEqual(
"new Level1('foo', 'Tỉnh Foo\"bar', Type.tinh, [\n]),"
"new Level1('foo', 'Tỉnh Foo\"bar', Type.tinh, [\n]),",
);
});

Expand All @@ -141,7 +141,7 @@ describe("generate", () => {
level2s: [],
});
expect(written.trim()).toEqual(
"new Level1('foo', 'Tỉnh \\'Foo\"bar', Type.tinh, [\n]),"
"new Level1('foo', 'Tỉnh \\'Foo\"bar', Type.tinh, [\n]),",
);
});

Expand Down
12 changes: 6 additions & 6 deletions transformers/js-dvhcvn/bin/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export function main(args: string[]): void {

stdout.write(
`\n\nexport const parents: Record<string,string> = ${JSON.stringify(
parents
)};`
parents,
)};`,
);
}

Expand All @@ -57,7 +57,7 @@ function _getType(str: string): string {
export function processLevel1(
parents: Parents,
level1Index: number,
level1: any
level1: any,
): void {
const id = _getString(level1.level1_id);
const name = _getString(level1.name);
Expand All @@ -78,7 +78,7 @@ export function processLevel2(
parents: Parents,
level1Index: number,
level2Index: number,
level2: any
level2: any,
): void {
const id = _getString(level2.level2_id);
const name = _getString(level2.name);
Expand All @@ -97,13 +97,13 @@ export function processLevel2(
export function processLevel3(
level1Index: number,
level2Index: number,
level3: any
level3: any,
): void {
const id = _getString(level3.level3_id);
const name = _getString(level3.name);
const type = _getType(level3.type);
stdout.writeln(
`new Level3(${level1Index}, ${level2Index}, ${id}, ${name}, ${type}),`
`new Level3(${level1Index}, ${level2Index}, ${id}, ${name}, ${type}),`,
);
}

Expand Down
Loading

0 comments on commit 8b965ea

Please sign in to comment.