forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RN: Cleanup
local-cli/core/__tests__
Reviewed By: raluca-elena Differential Revision: D5224347 fbshipit-source-id: 99a729c49bec28bf89d9dc91530958beec878828
- Loading branch information
1 parent
82edc13
commit 223eab9
Showing
11 changed files
with
369 additions
and
193 deletions.
There are no files selected for viewing
48 changes: 33 additions & 15 deletions
48
local-cli/core/__tests__/android/findAndroidAppFolder.spec.js
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,30 +1,48 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
jest.autoMockOff(); | ||
|
||
const mockFS = require('mock-fs'); | ||
|
||
const findAndroidAppFolder = require('../../android/findAndroidAppFolder'); | ||
const mockFs = require('mock-fs'); | ||
const mocks = require('../../__fixtures__/android'); | ||
|
||
describe('android::findAndroidAppFolder', () => { | ||
beforeAll(() => mockFs({ | ||
empty: {}, | ||
nested: { | ||
android: { | ||
app: mocks.valid, | ||
beforeAll(() => { | ||
mockFS({ | ||
empty: {}, | ||
nested: { | ||
android: { | ||
app: mocks.valid, | ||
}, | ||
}, | ||
}, | ||
flat: { | ||
android: mocks.valid, | ||
}, | ||
})); | ||
flat: { | ||
android: mocks.valid, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should return an android app folder if it exists in the given folder', () => { | ||
it('returns an android app folder if it exists in the given folder', () => { | ||
expect(findAndroidAppFolder('flat')).toBe('android'); | ||
expect(findAndroidAppFolder('nested')).toBe('android/app'); | ||
}); | ||
|
||
it('should return `null` if there\'s no android app folder', () => { | ||
expect(findAndroidAppFolder('empty')).toBe(null); | ||
it('returns `null` if there is no android app folder', () => { | ||
expect(findAndroidAppFolder('empty')).toBeNull(); | ||
}); | ||
|
||
afterAll(mockFs.restore); | ||
afterAll(() => { | ||
mockFS.restore(); | ||
}); | ||
}); |
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,25 +1,42 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
jest.autoMockOff(); | ||
|
||
const mockFS = require('mock-fs'); | ||
|
||
const findManifest = require('../../android/findManifest'); | ||
const mockFs = require('mock-fs'); | ||
const mocks = require('../../__fixtures__/android'); | ||
|
||
describe('android::findManifest', () => { | ||
beforeAll(() => { | ||
mockFS({ | ||
empty: {}, | ||
flat: { | ||
android: mocks.valid, | ||
}, | ||
}); | ||
}); | ||
|
||
beforeAll(() => mockFs({ | ||
empty: {}, | ||
flat: { | ||
android: mocks.valid, | ||
}, | ||
})); | ||
|
||
it('should return a manifest path if file exists in the folder', () => { | ||
it('returns a manifest path if file exists in the folder', () => { | ||
expect(typeof findManifest('flat')).toBe('string'); | ||
}); | ||
|
||
it('should return `null` if there is no manifest in the folder', () => { | ||
expect(findManifest('empty')).toBe(null); | ||
it('returns `null` if there is no manifest in the folder', () => { | ||
expect(findManifest('empty')).toBeNull(); | ||
}); | ||
|
||
afterAll(mockFs.restore); | ||
afterAll(() => { | ||
mockFS.restore(); | ||
}); | ||
}); |
41 changes: 29 additions & 12 deletions
41
local-cli/core/__tests__/android/findPackageClassName.spec.js
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,25 +1,42 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
jest.autoMockOff(); | ||
|
||
const mockFS = require('mock-fs'); | ||
|
||
const findPackageClassName = require('../../android/findPackageClassName'); | ||
const mockFs = require('mock-fs'); | ||
const mocks = require('../../__fixtures__/android'); | ||
|
||
describe('android::findPackageClassName', () => { | ||
beforeAll(() => { | ||
mockFS({ | ||
empty: {}, | ||
flat: { | ||
android: mocks.valid, | ||
}, | ||
}); | ||
}); | ||
|
||
beforeAll(() => mockFs({ | ||
empty: {}, | ||
flat: { | ||
android: mocks.valid, | ||
}, | ||
})); | ||
|
||
it('should return manifest content if file exists in the folder', () => { | ||
it('returns manifest content if file exists in the folder', () => { | ||
expect(typeof findPackageClassName('flat')).toBe('string'); | ||
}); | ||
|
||
it('should return `null` if there\'s no matches', () => { | ||
expect(findPackageClassName('empty')).toBe(null); | ||
it('returns `null` if there are no matches', () => { | ||
expect(findPackageClassName('empty')).toBeNull(); | ||
}); | ||
|
||
afterAll(mockFs.restore); | ||
afterAll(() => { | ||
mockFS.restore(); | ||
}); | ||
}); |
74 changes: 46 additions & 28 deletions
74
local-cli/core/__tests__/android/getDependencyConfig.spec.js
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,49 +1,67 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
jest.autoMockOff(); | ||
|
||
const mockFS = require('mock-fs'); | ||
|
||
const getDependencyConfig = require('../../android').dependencyConfig; | ||
const mockFs = require('mock-fs'); | ||
const mocks = require('../../__fixtures__/android'); | ||
|
||
const userConfig = {}; | ||
|
||
describe('android::getDependencyConfig', () => { | ||
|
||
beforeAll(() => mockFs({ | ||
empty: {}, | ||
nested: { | ||
android: { | ||
app: mocks.valid, | ||
beforeAll(() => { | ||
mockFS({ | ||
empty: {}, | ||
nested: { | ||
android: { | ||
app: mocks.valid, | ||
}, | ||
}, | ||
}, | ||
corrupted: { | ||
android: { | ||
app: mocks.corrupted, | ||
corrupted: { | ||
android: { | ||
app: mocks.corrupted, | ||
}, | ||
}, | ||
}, | ||
noPackage: { | ||
android: {}, | ||
}, | ||
})); | ||
|
||
it('should return an object with android project configuration', () => { | ||
expect(getDependencyConfig('nested', userConfig)).not.toBe(null); | ||
noPackage: { | ||
android: {}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('returns an object with android project configuration', () => { | ||
expect(getDependencyConfig('nested', userConfig)).not.toBeNull(); | ||
expect(typeof getDependencyConfig('nested', userConfig)).toBe('object'); | ||
}); | ||
|
||
it('should return `null` if manifest file hasn\'t been found', () => { | ||
expect(getDependencyConfig('empty', userConfig)).toBe(null); | ||
it('returns `null` if manifest file has not been found', () => { | ||
expect(getDependencyConfig('empty', userConfig)).toBeNull(); | ||
}); | ||
|
||
it('should return `null` if android project was not found', () => { | ||
expect(getDependencyConfig('empty', userConfig)).toBe(null); | ||
it('returns `null` if android project was not found', () => { | ||
expect(getDependencyConfig('empty', userConfig)).toBeNull(); | ||
}); | ||
|
||
it('should return `null` if android project does not contain ReactPackage', () => { | ||
expect(getDependencyConfig('noPackage', userConfig)).toBe(null); | ||
it('returns `null` if android project does not contain ReactPackage', () => { | ||
expect(getDependencyConfig('noPackage', userConfig)).toBeNull(); | ||
}); | ||
|
||
it('should return `null` if it can\'t find a packageClassName', () => { | ||
expect(getDependencyConfig('corrupted', userConfig)).toBe(null); | ||
it('returns `null` if it cannot find a packageClassName', () => { | ||
expect(getDependencyConfig('corrupted', userConfig)).toBeNull(); | ||
}); | ||
|
||
afterAll(mockFs.restore); | ||
afterAll(() => { | ||
mockFS.restore(); | ||
}); | ||
}); |
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
Oops, something went wrong.