-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
e046768
commit 95ef46f
Showing
7 changed files
with
203 additions
and
1 deletion.
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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,40 @@ | ||
import { stripIndent } from 'common-tags'; | ||
import { describe, expect as hardAssert, test } from 'vitest'; | ||
|
||
import { fixEmberReferences } from './ember.js'; | ||
|
||
const expect = hardAssert.soft; | ||
|
||
describe('fixReferences', () => { | ||
test('match ember-source', () => { | ||
let code = stripIndent` | ||
/// <reference types="ember-source/whatever/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixEmberReferences(code); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test('match multiple ember-source', () => { | ||
let code = stripIndent` | ||
/// <reference types="ember-source/whatever/module">" | ||
/// <reference types="ember-source/whatever1/module">" | ||
/// <reference types="ember-source/whatever2/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixEmberReferences(code); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test('ignore non-specified', () => { | ||
let code = stripIndent` | ||
/// <reference types="not-ember-source/whatever/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixEmberReferences(code); | ||
|
||
expect(result).toBe(code); | ||
}); | ||
}); |
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,45 @@ | ||
import { stripIndent } from 'common-tags'; | ||
import { describe, expect as hardAssert, test } from 'vitest'; | ||
|
||
import { fixGTSExtensions, fixOwnReferences } from './glint.js'; | ||
|
||
const expect = hardAssert.soft; | ||
|
||
describe('fixGTSExtensions', () => { | ||
test('works', () => { | ||
let code = stripIndent` | ||
import x from './foo.gts'; | ||
`; | ||
|
||
let result = fixGTSExtensions(code); | ||
|
||
expect(result).toBe(`import x from "./foo";`); | ||
}); | ||
}); | ||
|
||
describe('fixOwnReferences', () => { | ||
test('removes multiple', () => { | ||
let code = stripIndent` | ||
/// <reference types="node_modules/@glint/whatever/module">" | ||
/// <reference types="node_modules/@glint/whatever2/module">" | ||
/// <reference types="node_modules/@glint/whatever5/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixOwnReferences(code); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test(' does not remove more than what is specified', () => { | ||
let code = stripIndent` | ||
/// <reference types="@glint/whatever/module">" | ||
/// <reference types="node_modules/@glint/whatever2/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixOwnReferences(code); | ||
|
||
expect(result).toBe(stripIndent` | ||
/// <reference types="@glint/whatever/module">" | ||
export const two = 2;`); | ||
}); | ||
}); |
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,75 @@ | ||
import { stripIndent } from 'common-tags'; | ||
import { describe, expect as hardAssert, test } from 'vitest'; | ||
|
||
import { fixReferences } from './typescript.js'; | ||
|
||
const expect = hardAssert.soft; | ||
|
||
describe('fixReferences', () => { | ||
test('defaults: match ember-source', () => { | ||
let code = stripIndent` | ||
/// <reference types="ember-source/whatever/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixReferences(code); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test('defaults: match multiple ember-source', () => { | ||
let code = stripIndent` | ||
/// <reference types="ember-source/whatever/module">" | ||
/// <reference types="ember-source/whatever1/module">" | ||
/// <reference types="ember-source/whatever2/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixReferences(code); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test('defaults: ignore non-specified', () => { | ||
let code = stripIndent` | ||
/// <reference types="not-ember-source/whatever/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixReferences(code); | ||
|
||
expect(result).toBe(code); | ||
}); | ||
|
||
test('custom: works', () => { | ||
let code = stripIndent` | ||
/// <reference types="@glint/whatever/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixReferences(code, { types: '@glint' }); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test('custom: removes multiple', () => { | ||
let code = stripIndent` | ||
/// <reference types="@glint/whatever/module">" | ||
/// <reference types="@glint/whatever2/module">" | ||
/// <reference types="@glint/whatever5/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixReferences(code, { types: '@glint' }); | ||
|
||
expect(result).toBe(`export const two = 2;`); | ||
}); | ||
|
||
test('custom: does not remove more than what is specified', () => { | ||
let code = stripIndent` | ||
/// <reference types="@glint/whatever/module">" | ||
/// <reference types="node_modules/@glint/whatever2/module">" | ||
export const two = 2;`; | ||
|
||
let result = fixReferences(code, { types: '@glint' }); | ||
|
||
expect(result).toBe(stripIndent` | ||
/// <reference types="node_modules/@glint/whatever2/module">" | ||
export const two = 2;`); | ||
}); | ||
}); |