-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Assayyaad
committed
Aug 11, 2024
1 parent
7a3756b
commit 5f89367
Showing
15 changed files
with
1,143 additions
and
995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import clean from './func/clean.js' | ||
import read from './func/read.js' | ||
import write from './func/write.js' | ||
|
||
describe('cli', function () { | ||
describe('func', function () { | ||
describe('clean', function () { | ||
clean() | ||
}) | ||
|
||
describe('read', function () { | ||
read() | ||
}) | ||
|
||
describe('write', function () { | ||
write() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { equal } from 'assert/strict' | ||
import { cleanFile } from '../../src/func/clean.js' | ||
|
||
export default function () { | ||
describe('1: تنظيف الأسطر', function () { | ||
it('1.1: تحويل التصدير إلى التصدير الافتراضي', function () { | ||
const a = cleanFile('export = example;') | ||
equal(a, 'export default example;') | ||
}) | ||
|
||
it('1.2: يجب أن يبقى التصدير كما هو', function () { | ||
const a = cleanFile('export * as Types from "./file/path.js";') | ||
equal(a, 'export * as Types from "./file/path.js";') | ||
}) | ||
|
||
it('1.3: تحويل نوع التصدير إلى إعلان نوع التصدير', function () { | ||
const a = cleanFile('export type exports = example;') | ||
equal(a, 'export declare type exports = example;') | ||
}) | ||
|
||
it('1.4: يجب أن يبقى التصدير كما هو', function () { | ||
const a = cleanFile('export { example };') | ||
equal(a, 'export { example };') | ||
}) | ||
|
||
it('1.5: يجب أن يبقى استيراد النوع كما هو', function () { | ||
const a = cleanFile('import type { example } from "./file/path.js";') | ||
equal(a, 'import type { example } from "./file/path.js";') | ||
}) | ||
|
||
it('1.6: تحويل نوع التصدير إلى إعلان نوع التصدير', function () { | ||
const a = cleanFile('export type example = typeof import("./file/path.js");') | ||
equal(a, 'export declare type example = typeof import("./file/path.js");') | ||
}) | ||
|
||
it('1.7: تحويل دالة التصدير إلى دالة إعلان التصدير', function () { | ||
const a = | ||
cleanFile(`export function (...args: example[][], ...args2: example[example][], ...args3: example[][][]) : | ||
| Promise<import("file/path.js").example | void> | ||
| example | ||
| void { }`) | ||
equal( | ||
a, | ||
`import type { example } from "file/path.js"; | ||
export declare function (...args: example[], ...args2: example[example], ...args3: example[][]) : | ||
| Promise<example | void> | ||
| example | ||
| void { }` | ||
) | ||
}) | ||
|
||
it('1.8: تحويل تعداد التصدير إلى تعداد إعلان التصدير', function () { | ||
const a = cleanFile(`export enum Example = { | ||
other: import("../file/path.js").OtherExample; | ||
};`) | ||
equal( | ||
a, | ||
`import type { OtherExample } from "../file/path.js"; | ||
export declare enum Example = { | ||
other: OtherExample; | ||
};` | ||
) | ||
}) | ||
|
||
it('1.9: تحويل نوع التصدير إلى إعلان نوع التصدير مع تعليق', function () { | ||
const a = cleanFile( | ||
`export type Example = { | ||
/** | ||
* pretend to be a useful comment | ||
*/ | ||
some?: import("../file/path.js").SomeExample; | ||
};` | ||
) | ||
equal( | ||
a, | ||
`import type { SomeExample } from "../file/path.js"; | ||
export declare type Example = { | ||
/** | ||
* pretend to be a useful comment | ||
*/ | ||
some?: SomeExample; | ||
};` | ||
) | ||
}) | ||
|
||
it('1.10: تحويل نوع التصدير إلى إعلان نوع التصدير مع استيراد', function () { | ||
const a = cleanFile( | ||
'export declare type Example = import("./file/path").example1 | import("./file/path").example2;' | ||
) | ||
equal( | ||
a, | ||
`import type { example1, example2 } from "./file/path"; | ||
export declare type Example = example1 | example2;` | ||
) | ||
}) | ||
|
||
it('1.11: يجب أن يبقى الاستيراد كما هو', function () { | ||
const a = cleanFile('import { example } from "./file/path";') | ||
equal(a, 'import { example } from "./file/path";') | ||
}) | ||
|
||
it('1.12: تحويل استيراد إلى استيراد نوع', function () { | ||
const a = cleanFile(`const e1 = import("./file/path.js").Example1; | ||
const e2 = import("./file/path.js").Example2;`) | ||
equal( | ||
a, | ||
`import type { Example1, Example2 } from "./file/path.js"; | ||
const e1 = Example1; | ||
const e2 = Example2;` | ||
) | ||
}) | ||
|
||
it('1.13: إزالة تعريف النوع', function () { | ||
const a = cleanFile('/** @typedef {Example} Example */') | ||
equal(a, '') | ||
}) | ||
|
||
it('1.14: إزالة نوع التصدير', function () { | ||
const a = cleanFile('export type Example = Example;') | ||
equal(a, '') | ||
}) | ||
}) | ||
|
||
describe('2: تنظيف لا شيء', function () { | ||
it('2.1: يجب أن تعيده كما هو', function () { | ||
const a = cleanFile('function foo() { return 0 }') | ||
equal(a, 'function foo() { return 0 }') | ||
}) | ||
}) | ||
} |
Oops, something went wrong.