|
| 1 | +# |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# |
| 4 | +# This source code is licensed under the MIT license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | +# |
| 7 | + |
| 8 | +require('minitest/autorun') |
| 9 | + |
| 10 | +require_relative('../test_app') |
| 11 | + |
| 12 | +def app_manifest_path(project_root, podspec_path) |
| 13 | + File.join(project_root, podspec_path, 'ReactTestApp-Resources.podspec.json') |
| 14 | +end |
| 15 | + |
| 16 | +class TestTestApp < Minitest::Test |
| 17 | + def test_resources_pod_returns_spec_path |
| 18 | + assert_nil(resources_pod('/')) |
| 19 | + assert_nil(resources_pod('.')) |
| 20 | + |
| 21 | + project_root = File.join(__dir__, 'fixtures', 'without_resources') |
| 22 | + assert_nil(resources_pod(project_root)) |
| 23 | + |
| 24 | + project_root = File.join(__dir__, 'fixtures', 'without_resources', 'ios') |
| 25 | + assert_nil(resources_pod(project_root)) |
| 26 | + |
| 27 | + project_root = File.join(__dir__, 'fixtures', 'with_resources') |
| 28 | + assert_equal('.', resources_pod(project_root)) |
| 29 | + |
| 30 | + project_root = File.join(__dir__, 'fixtures', 'with_resources', 'ios') |
| 31 | + assert_equal('..', resources_pod(project_root)) |
| 32 | + end |
| 33 | + |
| 34 | + def test_resources_pod_writes_podspec |
| 35 | + [ |
| 36 | + File.join(__dir__, 'fixtures', 'with_resources'), |
| 37 | + File.join(__dir__, 'fixtures', 'with_resources', 'ios') |
| 38 | + ].each do |project_root| |
| 39 | + begin |
| 40 | + podspec_path = resources_pod(project_root) |
| 41 | + manifest_path = app_manifest_path(project_root, podspec_path) |
| 42 | + manifest = JSON.parse(File.read(manifest_path)) |
| 43 | + |
| 44 | + assert_equal(%w[dist/assets dist/main.jsbundle], manifest['resources'].sort) |
| 45 | + ensure |
| 46 | + File.delete(manifest_path) |
| 47 | + end |
| 48 | + end |
| 49 | + end |
| 50 | +end |
0 commit comments