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 'vendor/gems/ipynbdiff/spec/symbol_map_spec.rb')
-rw-r--r--vendor/gems/ipynbdiff/spec/symbol_map_spec.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/gems/ipynbdiff/spec/symbol_map_spec.rb b/vendor/gems/ipynbdiff/spec/symbol_map_spec.rb
new file mode 100644
index 00000000000..5fba47c85af
--- /dev/null
+++ b/vendor/gems/ipynbdiff/spec/symbol_map_spec.rb
@@ -0,0 +1,58 @@
+# frozen_string_literal: true
+
+require 'rspec'
+require 'json'
+require 'rspec-parameterized'
+require 'symbol_map'
+
+describe IpynbDiff::SymbolMap do
+ def res(*cases)
+ cases&.to_h || []
+ end
+
+ describe '#parse' do
+ subject { IpynbDiff::SymbolMap.parse(JSON.pretty_generate(source)) }
+
+ context 'Object with blank key' do
+ let(:source) { { "": { "": 5 } }}
+
+ it { is_expected.to match_array(res([".", 2], ["..", 3])) }
+ end
+
+ context 'Empty object' do
+ let(:source) { {} }
+
+ it { is_expected.to be_empty }
+ end
+
+ context 'Empty array' do
+ let(:source) { [] }
+
+ it { is_expected.to be_empty }
+ end
+
+ context 'Object with inner object and number' do
+ let(:source) { { obj1: { obj2: 1 } } }
+
+ it { is_expected.to match_array(res( ['.obj1', 2], ['.obj1.obj2', 3])) }
+ end
+
+ context 'Object with inner object and number, string and array with object' do
+ let(:source) { { obj1: { obj2: [123, 2, true], obj3: "hel\nlo", obj4: true, obj5: 123, obj6: 'a' } } }
+
+ it do
+ is_expected.to match_array(
+ res(['.obj1', 2],
+ ['.obj1.obj2', 3],
+ ['.obj1.obj2.0', 4],
+ ['.obj1.obj2.1', 5],
+ ['.obj1.obj2.2', 6],
+ ['.obj1.obj3', 8],
+ ['.obj1.obj4', 9],
+ ['.obj1.obj5', 10],
+ ['.obj1.obj6', 11])
+ )
+ end
+ end
+ end
+end