Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/api/entities/nuget/dependency_group_spec.rb')
-rw-r--r--spec/lib/api/entities/nuget/dependency_group_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/api/entities/nuget/dependency_group_spec.rb b/spec/lib/api/entities/nuget/dependency_group_spec.rb
new file mode 100644
index 00000000000..5a649be846b
--- /dev/null
+++ b/spec/lib/api/entities/nuget/dependency_group_spec.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe API::Entities::Nuget::DependencyGroup do
+ let(:dependency_group) do
+ {
+ id: 'http://gitlab.com/Sandbox.App/1.0.0.json#dependencygroup',
+ type: 'PackageDependencyGroup',
+ target_framework: 'fwk test',
+ dependencies: [
+ {
+ id: 'http://gitlab.com/Sandbox.App/1.0.0.json#dependency',
+ type: 'PackageDependency',
+ name: 'Dependency',
+ range: '2.0.0'
+ }
+ ]
+ }
+ end
+
+ let(:expected) do
+ {
+ '@id': 'http://gitlab.com/Sandbox.App/1.0.0.json#dependencygroup',
+ '@type': 'PackageDependencyGroup',
+ 'targetFramework': 'fwk test',
+ 'dependencies': [
+ {
+ '@id': 'http://gitlab.com/Sandbox.App/1.0.0.json#dependency',
+ '@type': 'PackageDependency',
+ 'id': 'Dependency',
+ 'range': '2.0.0'
+ }
+ ]
+ }
+ end
+ let(:entity) { described_class.new(dependency_group) }
+
+ subject { entity.as_json }
+
+ it { is_expected.to eq(expected) }
+
+ context 'dependency group without target framework' do
+ let(:dependency_group_with_no_target_framework) { dependency_group.tap { |dg| dg[:target_framework] = nil } }
+ let(:expected_no_target_framework) { expected.except(:targetFramework) }
+ let(:entity) { described_class.new(dependency_group_with_no_target_framework) }
+
+ it { is_expected.to eq(expected_no_target_framework) }
+ end
+end