2017-11-02 13:14:11 +00:00
|
|
|
/**
|
2018-02-09 01:10:29 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
2017-11-02 13:14:11 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* @emails oncall+javascript_foundation
|
|
|
|
*/
|
|
|
|
|
2016-07-30 15:59:16 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
const xcode = require('xcode');
|
2016-08-22 15:56:14 +00:00
|
|
|
const getGroup = require('../../ios/getGroup');
|
2016-07-30 15:59:16 +00:00
|
|
|
const path = require('path');
|
2016-05-20 11:52:08 +00:00
|
|
|
|
2016-07-30 15:59:16 +00:00
|
|
|
const project = xcode.project(
|
|
|
|
path.join(__dirname, '../../__fixtures__/project.pbxproj')
|
|
|
|
);
|
2016-05-20 11:52:08 +00:00
|
|
|
|
|
|
|
describe('ios::getGroup', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
project.parseSync();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a top-level group', () => {
|
|
|
|
const group = getGroup(project, 'Libraries');
|
2016-07-30 15:59:16 +00:00
|
|
|
expect(group.children.length > 0).toBeTruthy();
|
|
|
|
expect(group.name).toBe('Libraries');
|
2016-05-20 11:52:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should return nested group when specified', () => {
|
|
|
|
const group = getGroup(project, 'NestedGroup/Libraries');
|
2016-07-30 15:59:16 +00:00
|
|
|
expect(group.children.length).toBe(0); // our test nested Libraries is empty
|
|
|
|
expect(group.name).toBe('Libraries');
|
2016-05-20 11:52:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should return null when no group found', () => {
|
|
|
|
const group = getGroup(project, 'I-Dont-Exist');
|
2016-07-30 15:59:16 +00:00
|
|
|
expect(group).toBeNull();
|
2016-05-20 11:52:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should return top-level group when name not specified', () => {
|
|
|
|
const mainGroupId = project.getFirstProject().firstProject.mainGroup;
|
|
|
|
const mainGroup = project.getPBXGroupByKey(mainGroupId);
|
|
|
|
const group = getGroup(project);
|
2016-07-30 15:59:16 +00:00
|
|
|
expect(group).toEqual(mainGroup);
|
2016-05-20 11:52:08 +00:00
|
|
|
});
|
|
|
|
});
|