Skip to content

Commit 4808a7b

Browse files
committed
Adjusting the jasmine tests
1 parent df76d4e commit 4808a7b

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/customer-data.test.js

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
/* jscs:disable jsDoc*/
88

99
define([
10+
'underscore',
1011
'squire',
1112
'jquery',
1213
'Magento_Customer/js/section-config',
1314
'Magento_Customer/js/customer-data',
1415
'jquery/jquery-storageapi'
15-
], function (Squire, $, sectionConfig, customerData) {
16+
], function (_, Squire, $, sectionConfig, customerData) {
1617
'use strict';
1718

1819
var injector = new Squire(),
@@ -45,27 +46,6 @@ define([
4546
]
4647
};
4748

48-
var _;
49-
50-
beforeEach(function (done) {
51-
injector.require([
52-
'underscore',
53-
'Magento_Customer/js/customer-data'
54-
], function (underscore, Constr) {
55-
_ = underscore;
56-
obj = Constr;
57-
done();
58-
});
59-
});
60-
61-
afterEach(function () {
62-
try {
63-
injector.clean();
64-
injector.remove();
65-
} catch (e) {
66-
}
67-
});
68-
6949
function init(config) {
7050
var defaultConfig = {
7151
sectionLoadUrl: 'http://localhost/customer/section/load/',
@@ -109,22 +89,31 @@ define([
10989
);
11090
}
11191

112-
describe('Magento_Customer/js/customer-data', function () {
113-
function clearLocalStorage() {
114-
$.cookieStorage.set('section_data_ids', {});
92+
function clearLocalStorage() {
93+
$.cookieStorage.set('section_data_ids', {});
11594

116-
if (window.localStorage) {
117-
window.localStorage.clear();
118-
}
95+
if (window.localStorage) {
96+
window.localStorage.clear();
11997
}
98+
}
12099

100+
describe('Magento_Customer/js/customer-data', function () {
121101
beforeAll(function () {
122102
clearLocalStorage();
123103
});
124104

125-
beforeEach(function () {
105+
beforeEach(function (done) {
126106
originalGetJSON = $.getJSON;
127107
sectionConfig['Magento_Customer/js/section-config'](sectionConfigSettings);
108+
109+
injector.require([
110+
'underscore',
111+
'Magento_Customer/js/customer-data'
112+
], function (underscore, Constr) {
113+
_ = underscore;
114+
obj = Constr;
115+
done();
116+
});
128117
});
129118

130119
afterEach(function () {

0 commit comments

Comments
 (0)