-
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.
Add .aiignore file and update Config and Scopes tests
- Loading branch information
1 parent
9654b2c
commit d5422fd
Showing
5 changed files
with
103 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dist | ||
package-lock.json | ||
node_modules | ||
.git | ||
autom4te.cache |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import fs from "fs"; | ||
import os from "os"; | ||
import path from "path"; | ||
import ResourcePak from "../src/ResourcePak"; | ||
import Config from "../src/Config"; | ||
|
||
// Helper to create a temporary directory for testing | ||
function createTempDir(): string { | ||
return fs.mkdtempSync(path.join(os.tmpdir(), "resource-pak-")); | ||
} | ||
|
||
describe("ResourcePak", () => { | ||
let tempDir: string; | ||
let config: Config; | ||
let rp: ResourcePak; | ||
|
||
beforeEach(() => { | ||
tempDir = createTempDir(); | ||
const defaultConfig = { | ||
prefix: tempDir, // or any other default values your Config expects | ||
scopes: {} | ||
}; | ||
fs.writeFileSync(path.join(tempDir, 'config.json'), JSON.stringify(defaultConfig)); | ||
config = new Config(tempDir); | ||
rp = new ResourcePak(config, tempDir); | ||
}); | ||
|
||
afterEach(() => { | ||
fs.rmSync(tempDir, { recursive: true }); | ||
}); | ||
|
||
it("should create a new package", () => { | ||
const packageName = "@test/package"; | ||
rp.create(packageName); | ||
expect(rp.package).toBeDefined(); | ||
expect(rp.package?.name).toBe(packageName); | ||
// Add more assertions as necessary | ||
}); | ||
|
||
it("should add a resource", () => { | ||
const packageName = "@test/package"; | ||
rp.create(packageName); | ||
|
||
const resourceName = "testResource"; | ||
const fileName = "testFile.txt"; | ||
// Creating a dummy file to add | ||
const filePath = path.join(tempDir, fileName); | ||
fs.writeFileSync(filePath, "Dummy content"); | ||
rp.addResource(resourceName, filePath); | ||
|
||
expect(rp.package?.resources).toContainEqual(expect.objectContaining({ | ||
name: resourceName, | ||
filename: tempDir + "/" + fileName, | ||
// size: depends on the content written | ||
})); | ||
// Add more assertions as necessary | ||
}); | ||
|
||
it("should save package configuration", () => { | ||
const packageName = "@test/package"; | ||
rp.create(packageName); | ||
rp.savePackage(); | ||
const packageJsonPath = path.join(tempDir, "package.json"); | ||
expect(fs.existsSync(packageJsonPath)).toBe(true); | ||
// Further assertions on the contents of package.json can be added | ||
}); | ||
|
||
// Add more tests for other methods, e.g., build(), as needed. | ||
}); |
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