-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
45c56f7
commit 2e66bbb
Showing
10 changed files
with
87 additions
and
86 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 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,12 @@ | ||
import nock from "nock"; | ||
import { DomainName } from "../../src/domain/domain-name"; | ||
|
||
/** | ||
* Mocks the existence of a Unity documentation page for a package. | ||
* @param packageName The name of the package. | ||
*/ | ||
export function mockUnityDocPage(packageName: DomainName) { | ||
nock(`https://docs.unity3d.com`) | ||
.head(`/Manual/${packageName}.html`) | ||
.reply(200); | ||
} |
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 @@ | ||
import nock from "nock"; | ||
import { UnityPackument } from "../../src/domain/packument"; | ||
import { RegistryUrl, unityRegistryUrl } from "../../src/domain/registry-url"; | ||
|
||
/** | ||
* Mocks a packument on a remote package registry. | ||
* @param registryUrl The url of the registry. | ||
* @param packument The packument. | ||
*/ | ||
export function mockRegistryPackument( | ||
registryUrl: RegistryUrl, | ||
packument: UnityPackument | ||
) { | ||
nock(registryUrl).get(`/${packument.name}`).reply(200, packument); | ||
} | ||
|
||
/** | ||
* Mocks a packument on the Unity package registry. | ||
* @param packument The packument. | ||
*/ | ||
export function mockUnityRegistryPackument(packument: UnityPackument) { | ||
mockRegistryPackument(unityRegistryUrl, packument); | ||
} |
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,43 @@ | ||
import nock from "nock"; | ||
import { DomainName } from "../../../src/domain/domain-name"; | ||
import { SemanticVersion } from "../../../src/domain/semantic-version"; | ||
import { checkIsBuiltInPackage } from "../../../src/services/built-in-package-check"; | ||
import { buildPackument } from "../../data-packument"; | ||
import { mockUnityDocPage } from "../docs.mock"; | ||
import { mockUnityRegistryPackument } from "../registry.mock"; | ||
|
||
describe("check Unity package is built-in", () => { | ||
const somePackage = DomainName.parse("com.some.package"); | ||
const someVersion = SemanticVersion.parse("1.0.0"); | ||
|
||
beforeEach(() => { | ||
nock.cleanAll(); | ||
}); | ||
|
||
it("should be false if package is not a Unity package", async () => { | ||
const actual = await checkIsBuiltInPackage(somePackage, someVersion); | ||
|
||
expect(actual).toBeFalsy(); | ||
}); | ||
|
||
it("should be false if package is Unity package and exists on Unity registry", async () => { | ||
mockUnityDocPage(somePackage); | ||
mockUnityRegistryPackument( | ||
buildPackument(somePackage, (packument) => | ||
packument.addVersion(someVersion) | ||
) | ||
); | ||
|
||
const actual = await checkIsBuiltInPackage(somePackage, someVersion); | ||
|
||
expect(actual).toBeFalsy(); | ||
}); | ||
|
||
it("should be true if package is Unity package, but does not exist on Unity registry", async () => { | ||
mockUnityDocPage(somePackage); | ||
|
||
const actual = await checkIsBuiltInPackage(somePackage, someVersion); | ||
|
||
expect(actual).toBeTruthy(); | ||
}); | ||
}); |
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
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