|
| 1 | +/** |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + 'License'); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + Unless required by applicable law or agreed to in writing, |
| 11 | + software distributed under the License is distributed on an |
| 12 | + 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 13 | + KIND, either express or implied. See the License for the |
| 14 | + specific language governing permissions and limitations |
| 15 | + under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +var fullProject = require('./fixtures/full-project') |
| 19 | + fullProjectStr = JSON.stringify(fullProject), |
| 20 | + pbx = require('../lib/pbxProject'), |
| 21 | + pbxFile = require('../lib/pbxFile'), |
| 22 | + proj = new pbx('.'); |
| 23 | + |
| 24 | +function cleanHash() { |
| 25 | + return JSON.parse(fullProjectStr); |
| 26 | +} |
| 27 | + |
| 28 | +var TARGET_NAME = 'TestWatchApp', |
| 29 | + TARGET_TYPE = 'watch_app', |
| 30 | + TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; |
| 31 | + |
| 32 | +exports.setUp = function (callback) { |
| 33 | + proj.hash = cleanHash(); |
| 34 | + callback(); |
| 35 | +} |
| 36 | + |
| 37 | +exports.addWatchApp = { |
| 38 | + 'should create a new watch app target with the correct product type': function (test) { |
| 39 | + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); |
| 40 | + |
| 41 | + test.ok(typeof target == 'object'); |
| 42 | + test.ok(target.uuid); |
| 43 | + test.ok(target.pbxNativeTarget); |
| 44 | + test.ok(target.pbxNativeTarget.isa); |
| 45 | + test.ok(target.pbxNativeTarget.name); |
| 46 | + test.ok(target.pbxNativeTarget.productName); |
| 47 | + test.ok(target.pbxNativeTarget.productReference); |
| 48 | + test.ok(target.pbxNativeTarget.productType); |
| 49 | + test.ok(target.pbxNativeTarget.buildConfigurationList); |
| 50 | + test.ok(target.pbxNativeTarget.buildPhases); |
| 51 | + test.ok(target.pbxNativeTarget.buildRules); |
| 52 | + test.ok(target.pbxNativeTarget.dependencies); |
| 53 | + |
| 54 | + test.equal(target.pbxNativeTarget.productType, '"com.apple.product-type.application.watchapp"'); |
| 55 | + |
| 56 | + test.done(); |
| 57 | + }, |
| 58 | + 'should create a new watch app target with the correct product type, without needing a subfolder name': function (test) { |
| 59 | + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); |
| 60 | + |
| 61 | + test.ok(typeof target == 'object'); |
| 62 | + test.ok(target.uuid); |
| 63 | + test.ok(target.pbxNativeTarget); |
| 64 | + test.ok(target.pbxNativeTarget.isa); |
| 65 | + test.ok(target.pbxNativeTarget.name); |
| 66 | + test.ok(target.pbxNativeTarget.productName); |
| 67 | + test.ok(target.pbxNativeTarget.productReference); |
| 68 | + test.ok(target.pbxNativeTarget.productType); |
| 69 | + test.ok(target.pbxNativeTarget.buildConfigurationList); |
| 70 | + test.ok(target.pbxNativeTarget.buildPhases); |
| 71 | + test.ok(target.pbxNativeTarget.buildRules); |
| 72 | + test.ok(target.pbxNativeTarget.dependencies); |
| 73 | + |
| 74 | + test.equal(target.pbxNativeTarget.productType, '"com.apple.product-type.application.watchapp"'); |
| 75 | + |
| 76 | + test.done(); |
| 77 | + }, |
| 78 | + 'should create a new watch app target and add source, framework, resource and header files and the corresponding build phases': function (test) { |
| 79 | + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME), |
| 80 | + options = { 'target' : target.uuid }; |
| 81 | + |
| 82 | + var sourceFile = proj.addSourceFile('Plugins/file.m', options), |
| 83 | + sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid), |
| 84 | + resourceFile = proj.addResourceFile('assets.bundle', options), |
| 85 | + resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid), |
| 86 | + frameworkFile = proj.addFramework('libsqlite3.dylib', options); |
| 87 | + frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), |
| 88 | + headerFile = proj.addHeaderFile('file.h', options); |
| 89 | + |
| 90 | + test.ok(sourcePhase); |
| 91 | + test.ok(resourcePhase); |
| 92 | + test.ok(frameworkPhase); |
| 93 | + |
| 94 | + test.equal(sourceFile.constructor, pbxFile); |
| 95 | + test.equal(resourceFile.constructor, pbxFile); |
| 96 | + test.equal(frameworkFile.constructor, pbxFile); |
| 97 | + test.equal(headerFile.constructor, pbxFile); |
| 98 | + |
| 99 | + test.ok(typeof target == 'object'); |
| 100 | + test.ok(target.uuid); |
| 101 | + test.ok(target.pbxNativeTarget); |
| 102 | + test.ok(target.pbxNativeTarget.isa); |
| 103 | + test.ok(target.pbxNativeTarget.name); |
| 104 | + test.ok(target.pbxNativeTarget.productName); |
| 105 | + test.ok(target.pbxNativeTarget.productReference); |
| 106 | + test.ok(target.pbxNativeTarget.productType); |
| 107 | + test.ok(target.pbxNativeTarget.buildConfigurationList); |
| 108 | + test.ok(target.pbxNativeTarget.buildPhases); |
| 109 | + test.ok(target.pbxNativeTarget.buildRules); |
| 110 | + test.ok(target.pbxNativeTarget.dependencies); |
| 111 | + |
| 112 | + test.done(); |
| 113 | + } |
| 114 | +} |
0 commit comments