Files
qdr108 6f90ef7f07 Add asset utils resource identifier tests (#57999)
Summary:
Adds test coverage for `getAndroidResourceIdentifier` in `react-native/asset-utils`.

The tests cover folder path encoding, Android resource-name normalization, and generated asset path prefix removal.

## Changelog:
[INTERNAL] - Add test coverage for asset utils Android resource identifier normalization

Pull Request resolved: https://github.com/react/react-native/pull/57999

Test Plan:
Ran the package suite on this rebased commit:

```
yarn jest packages/asset-utils
# 1 suite, 7 passed (4 pre-existing, 3 new)
```

Checked that the three new cases are non-vacuous by mutating
`packages/asset-utils/src/AndroidPathUtils.js` one change at a time and re-running:

| mutation | result |
| --- | --- |
| narrow the prefix regex to `^assets_` | 1 failed, 6 passed |
| drop the `[^a-z0-9_]` illegal-char strip | 1 failed, 6 passed |
| drop `toLowerCase()` | 1 failed, 6 passed |
| restored | 7 passed |

Each new test kills exactly one distinct mutant, so all three assert real behavior
rather than padding coverage. The `^assets_` case matters most: the real regex is
`^(?:assets|assetsunstable_path)_`, where the first alternative matches `assets` then
fails on the following character, so the second alternative has to carry it.

This PR only adds `describe` blocks to an existing test file that was already running,
so there is no new test target to register.

Reviewed By: christophpurrer

Differential Revision: D117191484

Pulled By: fabriziocucci

fbshipit-source-id: 7a13c01772669eaf0ddfdf29156d8f250fd5cada
2026-08-24 08:35:52 -07:00
..
…

@react-native/asset-utils

npm npm downloads

Android resource-path helpers used when copying React Native assets into drawable-* / raw folders. Consumed by bundling and build tooling; most apps never import this directly.

API

import {
  getAndroidResourceFolderName,
  getAndroidResourceIdentifier,
} from '@react-native/asset-utils';
Export Signature Notes
getAndroidResourceFolderName (asset: PackagerAsset, scale: number) => string e.g. drawable-xhdpi; non-drawable types resolve to raw
getAndroidResourceIdentifier (asset: PackagerAsset) => string Sanitised resource name
drawableFileTypes Set<string> Asset types that map to a drawable-* folder