-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: plugin remove obsolete
gradle.properties
(#621)
- Loading branch information
1 parent
3a9a44d
commit 31bf300
Showing
2 changed files
with
35 additions
and
25 deletions.
There are no files selected for viewing
50 changes: 28 additions & 22 deletions
50
src/__tests__/plugin/android/mergeGradleProperties.test.ts
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 |
---|---|---|
@@ -1,37 +1,43 @@ | ||
import { mergeGradleProperties } from "../../../plugin/android"; | ||
import { | ||
GRADLE_PROPERTIES_PREFIX, | ||
mergeGradleProperties, | ||
} from "../../../plugin/android"; | ||
|
||
const PROPERTY = { | ||
const OTHER_PROPERTY = { | ||
type: "property", | ||
key: "exampleProperty", | ||
value: "value", | ||
key: `some.other.exampleProperty`, | ||
value: "example", | ||
} as const; | ||
|
||
const OLD_PROPERTY = { | ||
type: "property", | ||
key: `${GRADLE_PROPERTIES_PREFIX}exampleProperty`, | ||
value: "old", | ||
} as const; | ||
|
||
const NEW_PROPERTY = { | ||
type: "property", | ||
key: "newProperty", | ||
key: `${GRADLE_PROPERTIES_PREFIX}exampleProperty`, | ||
value: "new", | ||
} as const; | ||
|
||
describe("Expo Plugin Android – mergeGradleProperties", () => { | ||
it("replaces duplicate property", () => { | ||
expect( | ||
mergeGradleProperties( | ||
[ | ||
PROPERTY, | ||
{ | ||
...NEW_PROPERTY, | ||
value: "old", | ||
}, | ||
], | ||
[NEW_PROPERTY], | ||
), | ||
).toEqual([PROPERTY, NEW_PROPERTY]); | ||
}); | ||
|
||
it("adds new property", () => { | ||
expect(mergeGradleProperties([PROPERTY], [NEW_PROPERTY])).toEqual([ | ||
PROPERTY, | ||
expect(mergeGradleProperties([OTHER_PROPERTY], [NEW_PROPERTY])).toEqual([ | ||
OTHER_PROPERTY, | ||
NEW_PROPERTY, | ||
]); | ||
}); | ||
|
||
it("removes obsolete property", () => { | ||
expect(mergeGradleProperties([OTHER_PROPERTY, OLD_PROPERTY], [])).toEqual([ | ||
OTHER_PROPERTY, | ||
]); | ||
}); | ||
|
||
it("replaces property", () => { | ||
expect( | ||
mergeGradleProperties([OTHER_PROPERTY, OLD_PROPERTY], [NEW_PROPERTY]), | ||
).toEqual([OTHER_PROPERTY, NEW_PROPERTY]); | ||
}); | ||
}); |
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