mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
tests(prepare): factor out common vars (#1259)
This commit is contained in:
parent
69b24dbf6a
commit
334d02d26e
@ -94,23 +94,37 @@ function mockGetSplashScreenItem (data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('prepare', () => {
|
describe('prepare', () => {
|
||||||
describe('updateIcons method', function () {
|
|
||||||
// Rewire
|
// Rewire
|
||||||
let prepare;
|
let prepare;
|
||||||
|
|
||||||
|
// Spies
|
||||||
|
let emitSpy;
|
||||||
|
let updatePathsSpy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
||||||
|
|
||||||
|
emitSpy = jasmine.createSpy('emit');
|
||||||
|
prepare.__set__('events', {
|
||||||
|
emit: emitSpy
|
||||||
|
});
|
||||||
|
|
||||||
|
updatePathsSpy = jasmine.createSpy('updatePaths');
|
||||||
|
prepare.__set__('FileUpdater', {
|
||||||
|
updatePaths: updatePathsSpy
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('updateIcons method', function () {
|
||||||
// Spies
|
// Spies
|
||||||
let updateIconResourceForAdaptiveSpy;
|
let updateIconResourceForAdaptiveSpy;
|
||||||
let updateIconResourceForLegacySpy;
|
let updateIconResourceForLegacySpy;
|
||||||
let emitSpy;
|
|
||||||
let updatePathsSpy;
|
|
||||||
|
|
||||||
// Mock Data
|
// Mock Data
|
||||||
let cordovaProject;
|
let cordovaProject;
|
||||||
let platformResourcesDir;
|
let platformResourcesDir;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
cordovaProject = {
|
cordovaProject = {
|
||||||
root: '/mock',
|
root: '/mock',
|
||||||
projectConfig: {
|
projectConfig: {
|
||||||
@ -124,16 +138,6 @@ describe('prepare', () => {
|
|||||||
};
|
};
|
||||||
platformResourcesDir = PATH_RESOURCE;
|
platformResourcesDir = PATH_RESOURCE;
|
||||||
|
|
||||||
emitSpy = jasmine.createSpy('emit');
|
|
||||||
prepare.__set__('events', {
|
|
||||||
emit: emitSpy
|
|
||||||
});
|
|
||||||
|
|
||||||
updatePathsSpy = jasmine.createSpy('updatePaths');
|
|
||||||
prepare.__set__('FileUpdater', {
|
|
||||||
updatePaths: updatePathsSpy
|
|
||||||
});
|
|
||||||
|
|
||||||
// mocking initial responses for mapImageResources
|
// mocking initial responses for mapImageResources
|
||||||
prepare.__set__('mapImageResources', function (rootDir, subDir, type, resourceName) {
|
prepare.__set__('mapImageResources', function (rootDir, subDir, type, resourceName) {
|
||||||
if (resourceName.includes('ic_launcher.png')) {
|
if (resourceName.includes('ic_launcher.png')) {
|
||||||
@ -506,20 +510,10 @@ describe('prepare', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('prepareIcons method', function () {
|
describe('prepareIcons method', function () {
|
||||||
let prepare;
|
|
||||||
let emitSpy;
|
|
||||||
let prepareIcons;
|
let prepareIcons;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
prepareIcons = prepare.__get__('prepareIcons');
|
prepareIcons = prepare.__get__('prepareIcons');
|
||||||
|
|
||||||
// Creating Spies
|
|
||||||
emitSpy = jasmine.createSpy('emit');
|
|
||||||
prepare.__set__('events', {
|
|
||||||
emit: emitSpy
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Test#001 : should emit extra default icon found for adaptive use case.', function () {
|
it('Test#001 : should emit extra default icon found for adaptive use case.', function () {
|
||||||
@ -570,8 +564,6 @@ describe('prepare', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('updateIconResourceForLegacy method', function () {
|
describe('updateIconResourceForLegacy method', function () {
|
||||||
let prepare;
|
|
||||||
|
|
||||||
// Spies
|
// Spies
|
||||||
let fsWriteFileSyncSpy;
|
let fsWriteFileSyncSpy;
|
||||||
|
|
||||||
@ -581,8 +573,6 @@ describe('prepare', () => {
|
|||||||
let resourceMap;
|
let resourceMap;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
// Mocked Data
|
// Mocked Data
|
||||||
platformResourcesDir = PATH_RESOURCE;
|
platformResourcesDir = PATH_RESOURCE;
|
||||||
preparedIcons = {
|
preparedIcons = {
|
||||||
@ -618,8 +608,6 @@ describe('prepare', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('updateIconResourceForAdaptive method', function () {
|
describe('updateIconResourceForAdaptive method', function () {
|
||||||
let prepare;
|
|
||||||
|
|
||||||
// Spies
|
// Spies
|
||||||
let fsWriteFileSyncSpy;
|
let fsWriteFileSyncSpy;
|
||||||
|
|
||||||
@ -629,8 +617,6 @@ describe('prepare', () => {
|
|||||||
let resourceMap;
|
let resourceMap;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
// Mocked Data
|
// Mocked Data
|
||||||
platformResourcesDir = PATH_RESOURCE;
|
platformResourcesDir = PATH_RESOURCE;
|
||||||
preparedIcons = {
|
preparedIcons = {
|
||||||
@ -669,24 +655,6 @@ describe('prepare', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('cleanIcons method', function () {
|
describe('cleanIcons method', function () {
|
||||||
let prepare;
|
|
||||||
let emitSpy;
|
|
||||||
let updatePathsSpy;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
emitSpy = jasmine.createSpy('emit');
|
|
||||||
prepare.__set__('events', {
|
|
||||||
emit: emitSpy
|
|
||||||
});
|
|
||||||
|
|
||||||
updatePathsSpy = jasmine.createSpy('updatePaths');
|
|
||||||
prepare.__set__('FileUpdater', {
|
|
||||||
updatePaths: updatePathsSpy
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Test#001 : should detect that the app does not have defined icons.', function () {
|
it('Test#001 : should detect that the app does not have defined icons.', function () {
|
||||||
// Mock
|
// Mock
|
||||||
const icons = [];
|
const icons = [];
|
||||||
@ -767,10 +735,9 @@ describe('prepare', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('prepare arguments', () => {
|
describe('prepare arguments', () => {
|
||||||
// Rewire
|
// Rewire
|
||||||
let Api;
|
let Api;
|
||||||
let api;
|
let api;
|
||||||
let prepare;
|
|
||||||
|
|
||||||
// Spies
|
// Spies
|
||||||
let gradlePropertiesParserSpy;
|
let gradlePropertiesParserSpy;
|
||||||
@ -781,7 +748,6 @@ describe('prepare', () => {
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
Api = rewire('../../bin/templates/cordova/Api');
|
Api = rewire('../../bin/templates/cordova/Api');
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
cordovaProject = {
|
cordovaProject = {
|
||||||
root: '/mock',
|
root: '/mock',
|
||||||
@ -806,9 +772,6 @@ describe('prepare', () => {
|
|||||||
|
|
||||||
Api.__set__('prepare', prepare.prepare);
|
Api.__set__('prepare', prepare.prepare);
|
||||||
|
|
||||||
prepare.__set__('events', {
|
|
||||||
emit: jasmine.createSpy('emit')
|
|
||||||
});
|
|
||||||
prepare.__set__('updateUserProjectGradleConfig', jasmine.createSpy());
|
prepare.__set__('updateUserProjectGradleConfig', jasmine.createSpy());
|
||||||
prepare.__set__('updateWww', jasmine.createSpy());
|
prepare.__set__('updateWww', jasmine.createSpy());
|
||||||
prepare.__set__('updateProjectAccordingTo', jasmine.createSpy('updateProjectAccordingTo')
|
prepare.__set__('updateProjectAccordingTo', jasmine.createSpy('updateProjectAccordingTo')
|
||||||
@ -848,20 +811,11 @@ describe('prepare', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('updateSplashes method', function () {
|
describe('updateSplashes method', function () {
|
||||||
// Rewire
|
|
||||||
let prepare;
|
|
||||||
|
|
||||||
// Spies
|
|
||||||
let emitSpy;
|
|
||||||
let updatePathsSpy;
|
|
||||||
|
|
||||||
// Mock Data
|
// Mock Data
|
||||||
let cordovaProject;
|
let cordovaProject;
|
||||||
let platformResourcesDir;
|
let platformResourcesDir;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
prepare = rewire('../../bin/templates/cordova/lib/prepare');
|
|
||||||
|
|
||||||
cordovaProject = {
|
cordovaProject = {
|
||||||
root: '/mock',
|
root: '/mock',
|
||||||
projectConfig: {
|
projectConfig: {
|
||||||
@ -875,16 +829,6 @@ describe('prepare', () => {
|
|||||||
};
|
};
|
||||||
platformResourcesDir = PATH_RESOURCE;
|
platformResourcesDir = PATH_RESOURCE;
|
||||||
|
|
||||||
emitSpy = jasmine.createSpy('emit');
|
|
||||||
prepare.__set__('events', {
|
|
||||||
emit: emitSpy
|
|
||||||
});
|
|
||||||
|
|
||||||
updatePathsSpy = jasmine.createSpy('updatePaths');
|
|
||||||
prepare.__set__('FileUpdater', {
|
|
||||||
updatePaths: updatePathsSpy
|
|
||||||
});
|
|
||||||
|
|
||||||
// mocking initial responses for mapImageResources
|
// mocking initial responses for mapImageResources
|
||||||
prepare.__set__('makeSplashCleanupMap', (rootDir, resourcesDir) => ({
|
prepare.__set__('makeSplashCleanupMap', (rootDir, resourcesDir) => ({
|
||||||
[path.join(resourcesDir, 'drawable-mdpi/screen.png')]: null,
|
[path.join(resourcesDir, 'drawable-mdpi/screen.png')]: null,
|
||||||
|
Loading…
Reference in New Issue
Block a user