Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
470b4983
Commit
470b4983
authored
Jan 11, 2022
by
vvempati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make propsData an arg so we can use createComponent for CI minutes tests
parent
06df79bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
102 deletions
+105
-102
ee/spec/frontend/subscriptions/buy_addons_shared/app_spec.js
ee/spec/frontend/subscriptions/buy_addons_shared/app_spec.js
+105
-102
No files found.
ee/spec/frontend/subscriptions/buy_addons_shared/app_spec.js
View file @
470b4983
...
@@ -29,14 +29,25 @@ import { mockStoragePlans } from 'ee_jest/subscriptions/mock_data';
...
@@ -29,14 +29,25 @@ import { mockStoragePlans } from 'ee_jest/subscriptions/mock_data';
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueApollo
);
localVue
.
use
(
VueApollo
);
describe
(
'
Buy
Storage
App
'
,
()
=>
{
describe
(
'
Buy
Addons Shared
App
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
function
createComponent
(
apolloProvider
)
{
function
createComponent
(
apolloProvider
,
propsData
)
{
wrapper
=
shallowMountExtended
(
App
,
{
wrapper
=
shallowMountExtended
(
App
,
{
localVue
,
localVue
,
apolloProvider
,
apolloProvider
,
propsData
:
{
propsData
,
stubs
:
{
Checkout
,
AddonPurchaseDetails
,
OrderSummary
,
SummaryDetails
,
},
});
return
waitForPromises
();
}
const
STORAGE_ADDON_PROPS
=
{
config
:
{
config
:
{
alertText
:
''
,
alertText
:
''
,
formula
:
I18N_DETAILS_FORMULA
,
formula
:
I18N_DETAILS_FORMULA
,
...
@@ -53,17 +64,7 @@ describe('Buy Storage App', () => {
...
@@ -53,17 +64,7 @@ describe('Buy Storage App', () => {
tooltipNote
:
I18N_STORAGE_TOOLTIP_NOTE
,
tooltipNote
:
I18N_STORAGE_TOOLTIP_NOTE
,
},
},
tags
:
[
planTags
.
STORAGE_PLAN
],
tags
:
[
planTags
.
STORAGE_PLAN
],
},
};
stubs
:
{
Checkout
,
AddonPurchaseDetails
,
OrderSummary
,
SummaryDetails
,
},
});
return
waitForPromises
();
}
const
getStoragePlan
=
()
=>
pick
(
mockStoragePlans
[
0
],
[
'
id
'
,
'
code
'
,
'
pricePerYear
'
,
'
name
'
]);
const
getStoragePlan
=
()
=>
pick
(
mockStoragePlans
[
0
],
[
'
id
'
,
'
code
'
,
'
pricePerYear
'
,
'
name
'
]);
const
findCheckout
=
()
=>
wrapper
.
findComponent
(
Checkout
);
const
findCheckout
=
()
=>
wrapper
.
findComponent
(
Checkout
);
const
findOrderSummary
=
()
=>
wrapper
.
findComponent
(
OrderSummary
);
const
findOrderSummary
=
()
=>
wrapper
.
findComponent
(
OrderSummary
);
...
@@ -77,12 +78,13 @@ describe('Buy Storage App', () => {
...
@@ -77,12 +78,13 @@ describe('Buy Storage App', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
Storage
'
,
()
=>
{
describe
(
'
when data is received
'
,
()
=>
{
describe
(
'
when data is received
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
});
});
return
createComponent
(
mockApollo
);
return
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
});
});
it
(
'
should display the root element
'
,
()
=>
{
it
(
'
should display the root element
'
,
()
=>
{
...
@@ -109,7 +111,7 @@ describe('Buy Storage App', () => {
...
@@ -109,7 +111,7 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
null
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
null
}),
});
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
...
@@ -119,7 +121,7 @@ describe('Buy Storage App', () => {
...
@@ -119,7 +121,7 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
null
}
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
null
}
}),
});
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
...
@@ -129,7 +131,7 @@ describe('Buy Storage App', () => {
...
@@ -129,7 +131,7 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
{}
}
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
{}
}
}),
});
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
...
@@ -141,7 +143,7 @@ describe('Buy Storage App', () => {
...
@@ -141,7 +143,7 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockRejectedValue
(
new
Error
(
'
An error happened!
'
)),
plansQueryMock
:
jest
.
fn
().
mockRejectedValue
(
new
Error
(
'
An error happened!
'
)),
});
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
findRootElement
().
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlEmptyState
).
exists
()).
toBe
(
true
);
...
@@ -153,7 +155,7 @@ describe('Buy Storage App', () => {
...
@@ -153,7 +155,7 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
});
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findQuantityText
().
text
()).
toMatchInterpolatedText
(
expect
(
findQuantityText
().
text
()).
toMatchInterpolatedText
(
'
x 10 GB per pack = 10 GB of storage
'
,
'
x 10 GB per pack = 10 GB of storage
'
,
...
@@ -167,7 +169,7 @@ describe('Buy Storage App', () => {
...
@@ -167,7 +169,7 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
},
{
quantity
:
2
});
},
{
quantity
:
2
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findQuantityText
().
text
()).
toMatchInterpolatedText
(
expect
(
findQuantityText
().
text
()).
toMatchInterpolatedText
(
'
x 10 GB per pack = 20 GB of storage
'
,
'
x 10 GB per pack = 20 GB of storage
'
,
...
@@ -180,9 +182,10 @@ describe('Buy Storage App', () => {
...
@@ -180,9 +182,10 @@ describe('Buy Storage App', () => {
const
mockApollo
=
createMockApolloProvider
({
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
plansQueryMock
:
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
}),
},
{
quantity
:
-
1
});
},
{
quantity
:
-
1
});
await
createComponent
(
mockApollo
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
expect
(
findQuantityText
().
text
()).
toMatchInterpolatedText
(
'
x 10 GB per pack
'
);
expect
(
findQuantityText
().
text
()).
toMatchInterpolatedText
(
'
x 10 GB per pack
'
);
});
});
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment