Skip to content

Commit

Permalink
refactor(native): use resources for sources, add scale
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Jun 12, 2020
1 parent 5cb1a18 commit 038a05e
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 189 deletions.
28 changes: 18 additions & 10 deletions src/__tests__/resources.ts
Expand Up @@ -25,17 +25,18 @@ describe('cordova-res', () => {
});

describe('generateScaledWindowsResource', () => {
it('should generate scaled resource with proper src and format', () => {
const resource: ResourceConfig = {
platform: Platform.WINDOWS,
type: ResourceType.ICON,
src: 'dir/icon.png',
width: 100,
height: 100,
format: Format.NONE,
target: Target.STORE_LOGO,
};
const resource: ResourceConfig = {
platform: Platform.WINDOWS,
type: ResourceType.ICON,
src: 'dir/icon.png',
width: 100,
height: 100,
format: Format.NONE,
target: Target.STORE_LOGO,
scale: 1,
};

it('should generate scaled resource with proper src and format', () => {
const expected = {
platform: Platform.WINDOWS,
type: ResourceType.ICON,
Expand All @@ -44,10 +45,17 @@ describe('cordova-res', () => {
height: 150,
format: Format.PNG,
target: undefined,
scale: 1.5,
};

expect(generateScaledWindowsResource(resource, 1.5)).toEqual(expected);
});

it('should not allow scaled resource', () => {
expect(() =>
generateScaledWindowsResource({ ...resource, scale: 2 }, 1.5),
).toThrowError('from scaled resource');
});
});
});
});
4 changes: 2 additions & 2 deletions src/index.ts
Expand Up @@ -176,11 +176,11 @@ namespace CordovaRes {
export const run = CordovaRes;

export type PlatformOptions = {
[P in Platform]?: Readonly<RunPlatformOptions>;
[P in Platform]?: RunPlatformOptions;
};

export type NativeProjectConfigByPlatform = {
[P in Platform]?: Readonly<NativeProjectConfig>;
[P in Platform]?: NativeProjectConfig;
};

export type Operations = ResizeOptions & {
Expand Down

0 comments on commit 038a05e

Please sign in to comment.