-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can generate Info.plist factory with URL Types
- Loading branch information
1 parent
4f7f314
commit 0972915
Showing
2 changed files
with
36 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
import type { InfoPlist } from '@/src/types'; | ||
import { urlTypeFactory } from '@/tests/factories/urlType'; | ||
import { faker } from '@faker-js/faker'; | ||
import { Factory } from 'fishery'; | ||
|
||
class InfoPlistFactory extends Factory<InfoPlist, { urlSchemes?: boolean }> {} | ||
class InfoPlistFactory extends Factory<InfoPlist, { urlTypes?: number }> { | ||
urlTypes(count: number = 1) { | ||
return this.transient({ urlTypes: count }); | ||
} | ||
} | ||
|
||
export const infoPlistFactory = InfoPlistFactory.define(() => { | ||
const appName = faker.word.noun(); | ||
const domain = faker.internet.domainName(); | ||
const bundleId = domain.split(',').reverse().join('.') + '.' + appName; | ||
export const infoPlistFactory = InfoPlistFactory.define( | ||
({ transientParams }) => { | ||
const appName = faker.word.noun(); | ||
const domain = faker.internet.domainName(); | ||
const bundleId = domain.split(',').reverse().join('.') + '.' + appName; | ||
|
||
const infoPlist = { | ||
CFBundleDisplayName: appName, | ||
CFBundleIdentifier: bundleId, | ||
CFBundleName: appName, | ||
CFBundleShortVersionString: faker.system.semver(), | ||
}; | ||
const infoPlist: InfoPlist = { | ||
CFBundleDisplayName: appName, | ||
CFBundleIdentifier: bundleId, | ||
CFBundleName: appName, | ||
CFBundleShortVersionString: faker.system.semver(), | ||
}; | ||
|
||
return infoPlist; | ||
}); | ||
if (transientParams.urlTypes) { | ||
infoPlist.CFBundleURLTypes = urlTypeFactory.buildList( | ||
transientParams.urlTypes, | ||
); | ||
} | ||
|
||
return infoPlist; | ||
}, | ||
); |
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