forked from confused-Techie/atom-backend
-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
60f6be5
commit 21b8d89
Showing
4 changed files
with
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const pof = require("../../../src/models/constructPackageObjectFull.js"); | ||
const schema = require("../../models/packageObjectFull.js").test; | ||
|
||
describe("Parses Data, as expected to be returned by the Database", () => { | ||
|
||
test("Correctly Parses normal data", async () => { | ||
const data = { | ||
pointer: "1234", | ||
name: "test-package", | ||
created: "2024-01-20T00:47:00.981Z", | ||
updated: "2024-01-20T00:47:00.981Z", | ||
creation_method: "Test Package", | ||
downloads: "25", | ||
data: { | ||
name: "test-package", | ||
owner: "pulsar-edit", | ||
readme: "This is a readme!", | ||
metadata: { | ||
name: "test-package", | ||
license: "MIT", | ||
version: "1.0.0" | ||
}, | ||
releases: { latest: "1.0.0" }, | ||
versions: { | ||
"1.0.0": { | ||
sha: "1234", | ||
name: "test-package", | ||
version: "1.0.0", | ||
tarball_url: "https://nowhere.com" | ||
} | ||
}, | ||
repository: { | ||
url: "https://github.com/pulsar-edit/test-package", | ||
type: "git" | ||
}, | ||
creation_method: "Test Package" | ||
}, | ||
owner: "pulsar-edit", | ||
stargazers_count: "1", | ||
versions: [ | ||
{ | ||
id: 10, | ||
meta: { | ||
sha: "1234", | ||
name: "test-package", | ||
version: "1.0.0", | ||
tarball_url: "https://nowhere.com" | ||
}, | ||
engine: { atom: "*" }, | ||
semver: "1.0.0", | ||
license: "MIT", | ||
package: "1234", | ||
hasGrammar: false, | ||
hasSnippets: false, | ||
supportedLanguages: null | ||
} | ||
] | ||
}; | ||
|
||
const parsed = await pof(data); | ||
|
||
expect(parsed).toMatchSchema(schema); | ||
}); | ||
}); |
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,23 @@ | ||
const poj = require("../../../src/models/constructPackageObjectJSON.js"); | ||
const schema = require("../../models/packageObjectJSON.js").test; | ||
|
||
describe("Parses Data, as expected to be returned by the Database", () => { | ||
|
||
test("Correctly Parses normal data", async () => { | ||
const data = { | ||
semver: "1.0.0", | ||
license: "MIT", | ||
engines: { atom: "*" }, | ||
meta: { | ||
sha: "1234", | ||
name: "package-test", | ||
version: "1.0.0", | ||
tarball_url: "https://nowhere.com" | ||
} | ||
}; | ||
|
||
const parsed = await poj(data); | ||
|
||
expect(parsed).toMatchSchema(schema); | ||
}); | ||
}); |
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,46 @@ | ||
const pos = require("../../../src/models/constructPackageObjectShort.js"); | ||
const schema = require("../../models/packageObjectShort.js").test; | ||
|
||
describe("Parses Data, as expected to be returned by the Database", () => { | ||
|
||
test("Correctly Parses normal data", async () => { | ||
const data = { | ||
name: "test-package", | ||
data: { | ||
name: "test-package", | ||
owner: "pulsar-edit", | ||
readme: "This is a readme!", | ||
metadata: { | ||
name: "test-package", | ||
license: "MIT", | ||
version: "1.0.0" | ||
}, | ||
releases: { latest: "1.0.0" }, | ||
versions: { | ||
"1.0.0": { | ||
sha: "1234", | ||
name: "test-package", | ||
version: "1.0.0", | ||
tarball_url: "https://nowhere.com" | ||
} | ||
}, | ||
repository: { | ||
url: "https://github.com/pulsar-edit/test-package", | ||
type: "git" | ||
}, | ||
creation_method: "Test Package" | ||
}, | ||
downloads: "0", | ||
owner: "pulsar-edit", | ||
stargazers_count: "0", | ||
semver: "1.0.0", | ||
created: "2024-01-20T00:46:57.014Z", | ||
updated: "2024-01-20T00:46:57.014Z", | ||
creation_method: "Test Package" | ||
}; | ||
|
||
const parsed = await pos(data); | ||
|
||
expect(parsed).toMatchSchema(schema); | ||
}); | ||
}); |