-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a tolerance when finding a matching scale factor for android. Move "throw" statement into scale search routine, so that it always returns a real value (or throws). Add tests. * Remove dependency on mkdirp, and use nodejs "fs" instead. * Change files * PR feedback
- Loading branch information
Showing
7 changed files
with
119 additions
and
77 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@rnx-kit-metro-service-03514734-4444-485e-93ea-6393e433c081.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Remove dependency on mkdirp, and use nodejs \"fs\" instead. Add a tolerance when finding a matching scale factor for android. Move \"throw\" statement into scale search routine, so that it always returns a real value (or throws). Add tests.", | ||
"packageName": "@rnx-kit/metro-service", | ||
"email": "afoxman@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
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
5 changes: 5 additions & 0 deletions
5
packages/metro-service/test/asset/__snapshots__/android.test.ts.snap
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MetroService getAndroidAssetSuffix throw for invalid scale 0.70 1`] = `"Don't know which android drawable suffix to use for asset: {\\"httpServerLocation\\":\\"https://my-server.com/assets\\",\\"name\\":\\"logo\\",\\"type\\":\\"jpg\\"}"`; | ||
|
||
exports[`MetroService getAndroidAssetSuffix throw for invalid scale 1.23 1`] = `"Don't know which android drawable suffix to use for asset: {\\"httpServerLocation\\":\\"https://my-server.com/assets\\",\\"name\\":\\"logo\\",\\"type\\":\\"jpg\\"}"`; |
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,54 @@ | ||
import type { PackagerAsset } from "../../src/asset/types"; | ||
import { getAndroidAssetSuffix } from "../../src/asset/android"; | ||
|
||
describe("MetroService", () => { | ||
const asset: PackagerAsset = { | ||
httpServerLocation: "https://my-server.com/assets", | ||
name: "logo", | ||
type: "jpg", | ||
}; | ||
|
||
test("getAndroidAssetSuffix returns ldpi for scale 0.75", () => { | ||
expect(getAndroidAssetSuffix(asset, 0.75)).toEqual("ldpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns mdpi for scale 1", () => { | ||
expect(getAndroidAssetSuffix(asset, 1)).toEqual("mdpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns hdpi for scale 1.5", () => { | ||
expect(getAndroidAssetSuffix(asset, 1.5)).toEqual("hdpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns xhdpi for scale 2", () => { | ||
expect(getAndroidAssetSuffix(asset, 2)).toEqual("xhdpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns xxhdpi for scale 3", () => { | ||
expect(getAndroidAssetSuffix(asset, 3)).toEqual("xxhdpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns xxxhdpi for scale 4", () => { | ||
expect(getAndroidAssetSuffix(asset, 4)).toEqual("xxxhdpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns ldpi for scale 0.741", () => { | ||
expect(getAndroidAssetSuffix(asset, 0.741)).toEqual("ldpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix returns ldpi for scale 0.759", () => { | ||
expect(getAndroidAssetSuffix(asset, 0.759)).toEqual("ldpi"); | ||
}); | ||
|
||
test("getAndroidAssetSuffix throw for invalid scale 0.70", () => { | ||
expect(() => | ||
getAndroidAssetSuffix(asset, 0.7) | ||
).toThrowErrorMatchingSnapshot(); | ||
}); | ||
|
||
test("getAndroidAssetSuffix throw for invalid scale 1.23", () => { | ||
expect(() => | ||
getAndroidAssetSuffix(asset, 1.23) | ||
).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); |
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