Skip to content

Commit 4465f02

Browse files
committed
Add coverage for importing backend menu items into the admin
1 parent 0025c04 commit 4465f02

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

admin/spec/solidus_admin/configuration_spec.rb

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,95 @@
3939
expect(config.storefront_product_path(product)).to eq("/foo/bar/foo-bar-123")
4040
end
4141
end
42+
43+
describe "#import_menu_items_from_backend!" do
44+
it "imports the menu items from the backend" do
45+
allow(Spree::Backend::Config).to receive(:menu_items).and_return([
46+
Spree::BackendConfiguration::MenuItem.new(
47+
label: :item1,
48+
icon: 'ri-inbox-line',
49+
condition: -> {},
50+
match_path: %r{/foo},
51+
url: :foo,
52+
),
53+
Spree::BackendConfiguration::MenuItem.new(
54+
label: :item2,
55+
icon: 'shopping-cart',
56+
condition: -> {},
57+
match_path: -> {},
58+
url: "/bar"
59+
),
60+
Spree::BackendConfiguration::MenuItem.new(
61+
label: :item3,
62+
icon: 'shopping-cart',
63+
condition: -> {},
64+
match_path: "foo",
65+
url: -> {},
66+
),
67+
Spree::BackendConfiguration::MenuItem.new(
68+
label: :item4,
69+
icon: 'shopping-cart',
70+
condition: -> {},
71+
match_path: nil,
72+
url: nil,
73+
children: [
74+
Spree::BackendConfiguration::MenuItem.new(
75+
label: :item4_1,
76+
icon: 'shopping-cart',
77+
condition: -> {},
78+
match_path: nil,
79+
url: nil,
80+
),
81+
],
82+
),
83+
])
84+
85+
config = described_class.new
86+
config.import_menu_items_from_backend!
87+
88+
expect(config.menu_items).to match([
89+
{
90+
key: :item1,
91+
icon: 'inbox-line',
92+
route: a_kind_of(Proc),
93+
children: [],
94+
match_path: a_kind_of(Proc),
95+
position: 0,
96+
},
97+
{
98+
key: :item2,
99+
icon: 'record-circle-line',
100+
route: a_kind_of(Proc),
101+
children: [],
102+
match_path: a_kind_of(Proc),
103+
position: 1,
104+
},
105+
{
106+
key: :item3,
107+
icon: 'record-circle-line',
108+
route: a_kind_of(Proc),
109+
children: [],
110+
match_path: a_kind_of(Proc),
111+
position: 2,
112+
},
113+
{
114+
key: :item4,
115+
icon: 'record-circle-line',
116+
route: a_kind_of(Proc),
117+
children: [
118+
{
119+
key: :item4_1,
120+
icon: 'record-circle-line',
121+
route: a_kind_of(Proc),
122+
children: [],
123+
match_path: a_kind_of(Proc),
124+
position: 0,
125+
},
126+
],
127+
match_path: a_kind_of(Proc),
128+
position: 3,
129+
},
130+
])
131+
end
132+
end
42133
end

0 commit comments

Comments
 (0)