-
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.
update: used babel-plugin-tester instead of bare jest instructions
- Loading branch information
1 parent
eebc1cd
commit 116c578
Showing
9 changed files
with
15 additions
and
56 deletions.
There are no files selected for viewing
File renamed without changes.
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,3 @@ | ||
module.exports = { | ||
throws: true, | ||
}; |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
src/__tests__/fixtures/mix-default-specifier-usage/options.js
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,3 @@ | ||
module.exports = { | ||
throws: true, | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
module.exports = { | ||
throws: true, | ||
}; |
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 |
---|---|---|
@@ -1,60 +1,10 @@ | ||
import path from "node:path"; | ||
import fs from "node:fs"; | ||
import { transformFileSync } from "@babel/core"; | ||
import { pluginTester } from "babel-plugin-tester"; | ||
import plugin from "../index"; | ||
import { LUCIDE_REACT_NATIVE } from "../const"; | ||
|
||
describe("lucide-react-native modularized builds", () => { | ||
const fixturesDir = path.join(__dirname, "fixtures"); | ||
const errorFixturesDir = path.join(__dirname, "fixtures", "error"); | ||
|
||
fs.readdirSync(fixturesDir) | ||
.filter((caseName) => caseName !== "error") | ||
.map((caseName) => { | ||
const fixtureDir = path.join(fixturesDir, caseName); | ||
const actualFile = path.join(fixtureDir, "actual.js"); | ||
const expectedFile = path.join(fixtureDir, "expected.js"); | ||
|
||
describe(`should work with ${caseName.split("-").join(" ")}`, () => { | ||
// Programmatically test with the useES option both on and off | ||
it("cjs", () => { | ||
const actual = transformFileSync(actualFile, { | ||
compact: true, | ||
plugins: [plugin], | ||
})?.code?.trim(); | ||
const expected = transformFileSync(expectedFile, { | ||
compact: true, | ||
})?.code?.trim(); | ||
expect(actual).toBe(expected); | ||
}); | ||
|
||
it("esm", () => { | ||
const actual = transformFileSync(actualFile, { | ||
compact: true, | ||
plugins: [[plugin, { useES: true }]], | ||
})?.code; | ||
|
||
// The only difference is that cjs should be replaced with esm. This way, no changes to | ||
// the tests are needed to cover testing of useES. | ||
const expected = transformFileSync(expectedFile, { | ||
compact: true, | ||
})?.code?.replace(/cjs/g, "esm"); | ||
expect(actual).toBe(expected); | ||
}); | ||
}); | ||
}); | ||
|
||
fs.readdirSync(errorFixturesDir).map((caseName) => { | ||
const fixtureDir = path.join(fixturesDir, caseName); | ||
const actualFile = path.join(fixtureDir, "actual.js"); | ||
|
||
describe(`should throw an error with ${caseName.split("-").join(" ")}`, () => { | ||
it(`${caseName.split("-").join(" ")}`, () => { | ||
expect(function () { | ||
transformFileSync(actualFile, { | ||
plugins: [plugin], | ||
})?.code; | ||
}).toThrow(); | ||
}); | ||
}); | ||
}); | ||
pluginTester({ | ||
plugin, | ||
pluginName: LUCIDE_REACT_NATIVE, | ||
fixtures: path.join(__dirname, "fixtures"), | ||
}); |