mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-04 00:02:03 +08:00
refactor (eslint): use cordova-eslint (#910)
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
env:
|
||||
jasmine: true
|
||||
rules:
|
||||
prefer-promise-reject-errors: off
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
|
||||
let fs = require('fs-extra');
|
||||
const fs = require('fs-extra');
|
||||
var cp = require('child_process');
|
||||
var path = require('path');
|
||||
var util = require('util');
|
||||
@@ -77,7 +77,6 @@ module.exports.updateProject = function (projectid, platformpath, callback) {
|
||||
}
|
||||
callback(error);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -225,5 +225,4 @@ emulator-5554\tdevice
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -238,5 +238,4 @@ describe('AndroidManifest', () => {
|
||||
expect(fsSpy.writeFileSync).toHaveBeenCalledWith(jasmine.any(String), newXml, 'utf-8');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('android_sdk', () => {
|
||||
execaSpy.and.returnValue(Promise.resolve({ stdout: testTargets }));
|
||||
|
||||
return android_sdk.list_targets_with_android().then(list => {
|
||||
[ 'Google Inc.:Google APIs:23',
|
||||
['Google Inc.:Google APIs:23',
|
||||
'Google Inc.:Google APIs:22',
|
||||
'Google Inc.:Google APIs:21',
|
||||
'android-25',
|
||||
@@ -81,7 +81,7 @@ describe('android_sdk', () => {
|
||||
'android-MNC',
|
||||
'android-22',
|
||||
'android-21',
|
||||
'android-20' ].forEach((target) => expect(list).toContain(target));
|
||||
'android-20'].forEach((target) => expect(list).toContain(target));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
const rewire = require('rewire');
|
||||
let GradlePropertiesParser = rewire('../../../bin/templates/cordova/lib/config/GradlePropertiesParser');
|
||||
const GradlePropertiesParser = rewire('../../../bin/templates/cordova/lib/config/GradlePropertiesParser');
|
||||
|
||||
describe('Gradle Builder', () => {
|
||||
describe('_initializeEditor method', () => {
|
||||
@@ -91,8 +91,8 @@ describe('Gradle Builder', () => {
|
||||
});
|
||||
|
||||
it('should detect missing default property and sets the property.', () => {
|
||||
let setSpy = jasmine.createSpy('set');
|
||||
let getSpy = jasmine.createSpy('get').and.returnValue(false);
|
||||
const setSpy = jasmine.createSpy('set');
|
||||
const getSpy = jasmine.createSpy('get').and.returnValue(false);
|
||||
|
||||
parser.gradleFile = {
|
||||
set: setSpy,
|
||||
@@ -107,8 +107,8 @@ describe('Gradle Builder', () => {
|
||||
});
|
||||
|
||||
it('should not detect missing defaults and call set.', () => {
|
||||
let setSpy = jasmine.createSpy('set');
|
||||
let getSpy = jasmine.createSpy('get').and.returnValue(true);
|
||||
const setSpy = jasmine.createSpy('set');
|
||||
const getSpy = jasmine.createSpy('get').and.returnValue(true);
|
||||
|
||||
parser.gradleFile = {
|
||||
set: setSpy,
|
||||
@@ -122,8 +122,8 @@ describe('Gradle Builder', () => {
|
||||
});
|
||||
|
||||
it('should detect default with changed value to match default and set.', () => {
|
||||
let setSpy = jasmine.createSpy('set');
|
||||
let getSpy = jasmine.createSpy('get').and.returnValue('-Xmx512m');
|
||||
const setSpy = jasmine.createSpy('set');
|
||||
const getSpy = jasmine.createSpy('get').and.returnValue('-Xmx512m');
|
||||
|
||||
parser.gradleFile = {
|
||||
set: setSpy,
|
||||
@@ -138,8 +138,8 @@ describe('Gradle Builder', () => {
|
||||
});
|
||||
|
||||
it('should detect default with changed value different from default and set.', () => {
|
||||
let setSpy = jasmine.createSpy('set');
|
||||
let getSpy = jasmine.createSpy('get').and.returnValue('-Xmx2048m');
|
||||
const setSpy = jasmine.createSpy('set');
|
||||
const getSpy = jasmine.createSpy('get').and.returnValue('-Xmx2048m');
|
||||
|
||||
parser.gradleFile = {
|
||||
set: setSpy,
|
||||
|
||||
@@ -224,7 +224,6 @@ describe('create', function () {
|
||||
}, err => {
|
||||
expect(err).toBe(fakeError);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('emulator', () => {
|
||||
it('should properly parse details of SDK Tools 25.3.1 `avdmanager` output', () => {
|
||||
const avdList = fs.readFileSync(path.join('spec', 'fixtures', 'sdk25.3-avdmanager_list_avd.txt'), 'utf-8');
|
||||
|
||||
let execaSpy = jasmine.createSpy('execa').and.returnValue(Promise.resolve({ stdout: avdList }));
|
||||
const execaSpy = jasmine.createSpy('execa').and.returnValue(Promise.resolve({ stdout: avdList }));
|
||||
emu.__set__('execa', execaSpy);
|
||||
|
||||
return emu.list_images_using_avdmanager().then(list => {
|
||||
@@ -52,7 +52,7 @@ describe('emulator', () => {
|
||||
|
||||
describe('list_images_using_android', () => {
|
||||
it('should invoke `android` with the `list avd` command and _not_ the `list avds` command, as the plural form is not supported in some Android SDK Tools versions', () => {
|
||||
let execaSpy = jasmine.createSpy('execa').and.returnValue(Promise.resolve({ stdout: '' }));
|
||||
const execaSpy = jasmine.createSpy('execa').and.returnValue(Promise.resolve({ stdout: '' }));
|
||||
emu.__set__('execa', execaSpy);
|
||||
|
||||
emu.list_images_using_android();
|
||||
@@ -62,7 +62,7 @@ describe('emulator', () => {
|
||||
it('should properly parse details of SDK Tools pre-25.3.1 `android list avd` output', () => {
|
||||
const avdList = fs.readFileSync(path.join('spec', 'fixtures', 'sdk25.2-android_list_avd.txt'), 'utf-8');
|
||||
|
||||
let execaSpy = jasmine.createSpy('execa').and.returnValue(Promise.resolve({ stdout: avdList }));
|
||||
const execaSpy = jasmine.createSpy('execa').and.returnValue(Promise.resolve({ stdout: avdList }));
|
||||
emu.__set__('execa', execaSpy);
|
||||
|
||||
return emu.list_images_using_android().then(list => {
|
||||
|
||||
@@ -35,7 +35,6 @@ var deleteJava = common.__get__('deleteJava');
|
||||
var copyNewFile = common.__get__('copyNewFile');
|
||||
|
||||
describe('common platform handler', function () {
|
||||
|
||||
describe('copyFile', function () {
|
||||
it('Test#001 : should throw if source path not found', function () {
|
||||
fs.removeSync(src);
|
||||
|
||||
@@ -177,7 +177,6 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('of <framework> elements', function () {
|
||||
|
||||
var someString = jasmine.any(String);
|
||||
|
||||
var copyNewFileOrig = common.__get__('copyNewFile');
|
||||
@@ -280,9 +279,8 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('uninstallation', function () {
|
||||
|
||||
var deleteJavaOrig = common.__get__('deleteJava');
|
||||
let originalRemoveSync = fs.removeSync;
|
||||
const originalRemoveSync = fs.removeSync;
|
||||
var deleteJavaSpy = jasmine.createSpy('deleteJava');
|
||||
var dummyProject;
|
||||
let removeSyncSpy;
|
||||
@@ -387,7 +385,6 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('of <framework> elements', function () {
|
||||
|
||||
var someString = jasmine.any(String);
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
@@ -29,7 +29,7 @@ const PATH_RESOURCE = path.join('platforms', 'android', 'app', 'src', 'main', 'r
|
||||
* @param {String} target specific resource item
|
||||
*/
|
||||
function createResourceMap (target) {
|
||||
let resources = {};
|
||||
const resources = {};
|
||||
|
||||
[
|
||||
'mipmap-ldpi',
|
||||
@@ -152,8 +152,8 @@ describe('updateIcons method', function () {
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
|
||||
// The emit message was.
|
||||
let actual = emitSpy.calls.argsFor(0)[1];
|
||||
let expected = 'This app does not have launcher icons defined';
|
||||
const actual = emitSpy.calls.argsFor(0)[1];
|
||||
const expected = 'This app does not have launcher icons defined';
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -340,11 +340,11 @@ describe('updateIcons method', function () {
|
||||
};
|
||||
|
||||
// Creating Spies
|
||||
let resourceMap = createResourceMap();
|
||||
let phaseOneModification = {};
|
||||
const resourceMap = createResourceMap();
|
||||
const phaseOneModification = {};
|
||||
phaseOneModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_foreground.png')] = 'res/icon/android/mdpi-foreground.png';
|
||||
phaseOneModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_background.png')] = 'res/icon/android/mdpi-background.png';
|
||||
let phaseOneUpdatedIconsForAdaptive = Object.assign({}, resourceMap, phaseOneModification);
|
||||
const phaseOneUpdatedIconsForAdaptive = Object.assign({}, resourceMap, phaseOneModification);
|
||||
|
||||
updateIconResourceForAdaptiveSpy = jasmine.createSpy('updateIconResourceForAdaptiveSpy');
|
||||
prepare.__set__('updateIconResourceForAdaptive', function (preparedIcons, resourceMap, platformResourcesDir) {
|
||||
@@ -352,10 +352,10 @@ describe('updateIcons method', function () {
|
||||
return phaseOneUpdatedIconsForAdaptive;
|
||||
});
|
||||
|
||||
let phaseTwoModification = {};
|
||||
const phaseTwoModification = {};
|
||||
phaseTwoModification[path.join(PATH_RESOURCE, 'mipmap-mdpi', 'ic_launcher.png')] = 'res/icon/android/mdpi-foreground.png';
|
||||
phaseTwoModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_background.png')] = 'res/icon/android/mdpi-background.png';
|
||||
let phaseTwoUpdatedIconsForLegacy = Object.assign({}, phaseOneUpdatedIconsForAdaptive, phaseTwoModification);
|
||||
const phaseTwoUpdatedIconsForLegacy = Object.assign({}, phaseOneUpdatedIconsForAdaptive, phaseTwoModification);
|
||||
|
||||
updateIconResourceForLegacySpy = jasmine.createSpy('updateIconResourceForLegacySpy');
|
||||
prepare.__set__('updateIconResourceForLegacy', function (preparedIcons, resourceMap, platformResourcesDir) {
|
||||
@@ -369,8 +369,8 @@ describe('updateIcons method', function () {
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
|
||||
// The emit message was.
|
||||
let actual = emitSpy.calls.argsFor(0)[1];
|
||||
let expected = 'Updating icons at ' + PATH_RESOURCE;
|
||||
const actual = emitSpy.calls.argsFor(0)[1];
|
||||
const expected = 'Updating icons at ' + PATH_RESOURCE;
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
// Expected to be called.
|
||||
@@ -378,8 +378,8 @@ describe('updateIcons method', function () {
|
||||
expect(updateIconResourceForAdaptiveSpy).toHaveBeenCalled();
|
||||
expect(updateIconResourceForLegacySpy).toHaveBeenCalled();
|
||||
|
||||
let actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
let expectedResourceMap = phaseTwoUpdatedIconsForLegacy;
|
||||
const actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
const expectedResourceMap = phaseTwoUpdatedIconsForLegacy;
|
||||
expect(actualResourceMap).toEqual(expectedResourceMap);
|
||||
});
|
||||
|
||||
@@ -397,11 +397,11 @@ describe('updateIcons method', function () {
|
||||
};
|
||||
|
||||
// Creating Spies
|
||||
let resourceMap = createResourceMap();
|
||||
let phaseOneModification = {};
|
||||
const resourceMap = createResourceMap();
|
||||
const phaseOneModification = {};
|
||||
phaseOneModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_foreground.png')] = 'res/icon/android/mdpi-foreground.png';
|
||||
phaseOneModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_background.png')] = 'res/icon/android/mdpi-background.png';
|
||||
let phaseOneUpdatedIconsForAdaptive = Object.assign({}, resourceMap, phaseOneModification);
|
||||
const phaseOneUpdatedIconsForAdaptive = Object.assign({}, resourceMap, phaseOneModification);
|
||||
|
||||
updateIconResourceForAdaptiveSpy = jasmine.createSpy('updateIconResourceForAdaptiveSpy');
|
||||
prepare.__set__('updateIconResourceForAdaptive', function (preparedIcons, resourceMap, platformResourcesDir) {
|
||||
@@ -409,10 +409,10 @@ describe('updateIcons method', function () {
|
||||
return phaseOneUpdatedIconsForAdaptive;
|
||||
});
|
||||
|
||||
let phaseTwoModification = {};
|
||||
const phaseTwoModification = {};
|
||||
phaseTwoModification[path.join(PATH_RESOURCE, 'mipmap-mdpi', 'ic_launcher.png')] = 'res/icon/android/mdpi-foreground.png';
|
||||
phaseTwoModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_background.png')] = 'res/icon/android/mdpi-background.png';
|
||||
let phaseTwoUpdatedIconsForLegacy = Object.assign({}, phaseOneUpdatedIconsForAdaptive, phaseTwoModification);
|
||||
const phaseTwoUpdatedIconsForLegacy = Object.assign({}, phaseOneUpdatedIconsForAdaptive, phaseTwoModification);
|
||||
|
||||
updateIconResourceForLegacySpy = jasmine.createSpy('updateIconResourceForLegacySpy');
|
||||
prepare.__set__('updateIconResourceForLegacy', function (preparedIcons, resourceMap, platformResourcesDir) {
|
||||
@@ -426,8 +426,8 @@ describe('updateIcons method', function () {
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
|
||||
// The emit message was.
|
||||
let actual = emitSpy.calls.argsFor(0)[1];
|
||||
let expected = 'Updating icons at ' + PATH_RESOURCE;
|
||||
const actual = emitSpy.calls.argsFor(0)[1];
|
||||
const expected = 'Updating icons at ' + PATH_RESOURCE;
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
// Expected to be called.
|
||||
@@ -435,8 +435,8 @@ describe('updateIcons method', function () {
|
||||
expect(updateIconResourceForAdaptiveSpy).toHaveBeenCalled();
|
||||
expect(updateIconResourceForLegacySpy).toHaveBeenCalled();
|
||||
|
||||
let actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
let expectedResourceMap = phaseTwoUpdatedIconsForLegacy;
|
||||
const actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
const expectedResourceMap = phaseTwoUpdatedIconsForLegacy;
|
||||
expect(actualResourceMap).toEqual(expectedResourceMap);
|
||||
});
|
||||
|
||||
@@ -452,7 +452,7 @@ describe('updateIcons method', function () {
|
||||
};
|
||||
|
||||
// Creating Spies
|
||||
let phaseOneUpdatedIconsForAdaptive = createResourceMap();
|
||||
const phaseOneUpdatedIconsForAdaptive = createResourceMap();
|
||||
|
||||
updateIconResourceForAdaptiveSpy = jasmine.createSpy('updateIconResourceForAdaptiveSpy');
|
||||
prepare.__set__('updateIconResourceForAdaptive', function (preparedIcons, resourceMap, platformResourcesDir) {
|
||||
@@ -460,9 +460,9 @@ describe('updateIcons method', function () {
|
||||
return phaseOneUpdatedIconsForAdaptive;
|
||||
});
|
||||
|
||||
let phaseTwoModification = {};
|
||||
const phaseTwoModification = {};
|
||||
phaseTwoModification[path.join(PATH_RESOURCE, 'mipmap-mdpi', 'ic_launcher.png')] = 'res/icon/android/mdpi-icon.png';
|
||||
let phaseTwoUpdatedIconsForLegacy = Object.assign({}, phaseOneUpdatedIconsForAdaptive, phaseTwoModification);
|
||||
const phaseTwoUpdatedIconsForLegacy = Object.assign({}, phaseOneUpdatedIconsForAdaptive, phaseTwoModification);
|
||||
|
||||
updateIconResourceForLegacySpy = jasmine.createSpy('updateIconResourceForLegacySpy');
|
||||
prepare.__set__('updateIconResourceForLegacy', function (preparedIcons, resourceMap, platformResourcesDir) {
|
||||
@@ -476,8 +476,8 @@ describe('updateIcons method', function () {
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
|
||||
// The emit message was.
|
||||
let actual = emitSpy.calls.argsFor(0)[1];
|
||||
let expected = 'Updating icons at ' + PATH_RESOURCE;
|
||||
const actual = emitSpy.calls.argsFor(0)[1];
|
||||
const expected = 'Updating icons at ' + PATH_RESOURCE;
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
// Expected to be called.
|
||||
@@ -485,8 +485,8 @@ describe('updateIcons method', function () {
|
||||
expect(updateIconResourceForAdaptiveSpy).not.toHaveBeenCalled();
|
||||
expect(updateIconResourceForLegacySpy).toHaveBeenCalled();
|
||||
|
||||
let actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
let expectedResourceMap = phaseTwoUpdatedIconsForLegacy;
|
||||
const actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
const expectedResourceMap = phaseTwoUpdatedIconsForLegacy;
|
||||
expect(actualResourceMap).toEqual(expectedResourceMap);
|
||||
});
|
||||
});
|
||||
@@ -510,50 +510,48 @@ describe('prepareIcons method', function () {
|
||||
|
||||
it('Test#001 : should emit extra default icon found for adaptive use case.', function () {
|
||||
// mock data.
|
||||
let ldpi = mockGetIconItem({
|
||||
const ldpi = mockGetIconItem({
|
||||
density: 'ldpi',
|
||||
background: 'res/icon/android/ldpi-background.png',
|
||||
foreground: 'res/icon/android/ldpi-foreground.png'
|
||||
});
|
||||
|
||||
let mdpi = mockGetIconItem({
|
||||
const mdpi = mockGetIconItem({
|
||||
density: 'mdpi',
|
||||
background: 'res/icon/android/mdpi-background.png',
|
||||
foreground: 'res/icon/android/mdpi-foreground.png'
|
||||
});
|
||||
|
||||
let icons = [ldpi, mdpi];
|
||||
let actual = prepareIcons(icons);
|
||||
let expected = {
|
||||
const icons = [ldpi, mdpi];
|
||||
const actual = prepareIcons(icons);
|
||||
const expected = {
|
||||
android_icons: { ldpi, mdpi },
|
||||
default_icon: undefined
|
||||
};
|
||||
|
||||
expect(expected).toEqual(actual);
|
||||
|
||||
});
|
||||
|
||||
it('Test#002 : should emit extra default icon found for legacy use case.', function () {
|
||||
// mock data.
|
||||
let ldpi = mockGetIconItem({
|
||||
const ldpi = mockGetIconItem({
|
||||
src: 'res/icon/android/ldpi-icon.png',
|
||||
density: 'ldpi'
|
||||
});
|
||||
|
||||
let mdpi = mockGetIconItem({
|
||||
const mdpi = mockGetIconItem({
|
||||
src: 'res/icon/android/mdpi-icon.png',
|
||||
density: 'mdpi'
|
||||
});
|
||||
|
||||
let icons = [ldpi, mdpi];
|
||||
let actual = prepareIcons(icons);
|
||||
let expected = {
|
||||
const icons = [ldpi, mdpi];
|
||||
const actual = prepareIcons(icons);
|
||||
const expected = {
|
||||
android_icons: { ldpi, mdpi },
|
||||
default_icon: undefined
|
||||
};
|
||||
|
||||
expect(expected).toEqual(actual);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -596,13 +594,12 @@ describe('updateIconResourceForLegacy method', function () {
|
||||
const updateIconResourceForLegacy = prepare.__get__('updateIconResourceForLegacy');
|
||||
|
||||
// Run Test
|
||||
let expectedModification = {};
|
||||
const expectedModification = {};
|
||||
expectedModification[path.join(PATH_RESOURCE, 'mipmap-mdpi', 'ic_launcher.png')] = 'res/icon/android/mdpi-icon.png';
|
||||
let expected = Object.assign({}, resourceMap, expectedModification);
|
||||
let actual = updateIconResourceForLegacy(preparedIcons, resourceMap, platformResourcesDir);
|
||||
const expected = Object.assign({}, resourceMap, expectedModification);
|
||||
const actual = updateIconResourceForLegacy(preparedIcons, resourceMap, platformResourcesDir);
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -646,15 +643,14 @@ describe('updateIconResourceForAdaptive method', function () {
|
||||
const updateIconResourceForAdaptive = prepare.__get__('updateIconResourceForAdaptive');
|
||||
|
||||
// Run Test
|
||||
let expectedModification = {};
|
||||
const expectedModification = {};
|
||||
expectedModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_background.png')] = 'res/icon/android/mdpi-background.png';
|
||||
expectedModification[path.join(PATH_RESOURCE, 'mipmap-mdpi-v26', 'ic_launcher_foreground.png')] = 'res/icon/android/mdpi-foreground.png';
|
||||
|
||||
let expected = Object.assign({}, resourceMap, expectedModification);
|
||||
let actual = updateIconResourceForAdaptive(preparedIcons, resourceMap, platformResourcesDir);
|
||||
const expected = Object.assign({}, resourceMap, expectedModification);
|
||||
const actual = updateIconResourceForAdaptive(preparedIcons, resourceMap, platformResourcesDir);
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -679,36 +675,36 @@ describe('cleanIcons method', function () {
|
||||
|
||||
it('Test#001 : should detect that the app does not have defined icons.', function () {
|
||||
// Mock
|
||||
let icons = [];
|
||||
let projectRoot = '/mock';
|
||||
let projectConfig = {
|
||||
const icons = [];
|
||||
const projectRoot = '/mock';
|
||||
const projectConfig = {
|
||||
getIcons: function () { return icons; },
|
||||
path: '/mock/config.xml',
|
||||
cdvNamespacePrefix: 'cdv'
|
||||
};
|
||||
let platformResourcesDir = PATH_RESOURCE;
|
||||
const platformResourcesDir = PATH_RESOURCE;
|
||||
|
||||
const cleanIcons = prepare.__get__('cleanIcons');
|
||||
cleanIcons(projectRoot, projectConfig, platformResourcesDir);
|
||||
|
||||
let actualEmitMessage = emitSpy.calls.argsFor(0)[1];
|
||||
const actualEmitMessage = emitSpy.calls.argsFor(0)[1];
|
||||
expect(actualEmitMessage).toContain('This app does not have launcher icons defined');
|
||||
});
|
||||
|
||||
it('Test#002 : Should clean paths for adaptive icons.', function () {
|
||||
// Mock
|
||||
let icons = [mockGetIconItem({
|
||||
const icons = [mockGetIconItem({
|
||||
density: 'mdpi',
|
||||
background: 'res/icon/android/mdpi-background.png',
|
||||
foreground: 'res/icon/android/mdpi-foreground.png'
|
||||
})];
|
||||
let projectRoot = '/mock';
|
||||
let projectConfig = {
|
||||
const projectRoot = '/mock';
|
||||
const projectConfig = {
|
||||
getIcons: function () { return icons; },
|
||||
path: '/mock/config.xml',
|
||||
cdvNamespacePrefix: 'cdv'
|
||||
};
|
||||
let platformResourcesDir = PATH_RESOURCE;
|
||||
const platformResourcesDir = PATH_RESOURCE;
|
||||
|
||||
var expectedResourceMapBackground = createResourceMap('ic_launcher_background.png');
|
||||
|
||||
@@ -722,24 +718,24 @@ describe('cleanIcons method', function () {
|
||||
const cleanIcons = prepare.__get__('cleanIcons');
|
||||
cleanIcons(projectRoot, projectConfig, platformResourcesDir);
|
||||
|
||||
let actualResourceMapBackground = updatePathsSpy.calls.argsFor(0)[0];
|
||||
const actualResourceMapBackground = updatePathsSpy.calls.argsFor(0)[0];
|
||||
expect(actualResourceMapBackground).toEqual(expectedResourceMapBackground);
|
||||
});
|
||||
|
||||
it('Test#003 : Should clean paths for legacy icons.', function () {
|
||||
// Mock
|
||||
let icons = [mockGetIconItem({
|
||||
const icons = [mockGetIconItem({
|
||||
src: 'res/icon/android/mdpi.png',
|
||||
density: 'mdpi'
|
||||
})];
|
||||
|
||||
let projectRoot = '/mock';
|
||||
let projectConfig = {
|
||||
const projectRoot = '/mock';
|
||||
const projectConfig = {
|
||||
getIcons: function () { return icons; },
|
||||
path: '/mock/config.xml',
|
||||
cdvNamespacePrefix: 'cdv'
|
||||
};
|
||||
let platformResourcesDir = PATH_RESOURCE;
|
||||
const platformResourcesDir = PATH_RESOURCE;
|
||||
|
||||
var expectedResourceMap = createResourceMap();
|
||||
|
||||
@@ -751,7 +747,7 @@ describe('cleanIcons method', function () {
|
||||
const cleanIcons = prepare.__get__('cleanIcons');
|
||||
cleanIcons(projectRoot, projectConfig, platformResourcesDir);
|
||||
|
||||
let actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
const actualResourceMap = updatePathsSpy.calls.argsFor(0)[0];
|
||||
expect(actualResourceMap).toEqual(expectedResourceMap);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user