Passed
Push — master ( 366f40...c67819 )
by Christian
13:04 queued 10s
created

test/core/service/api/store.api.service.spec.js (3 issues)

1
import StoreApiService from 'src/core/service/api/store.api.service';
2
import createLoginService from 'src/core/service/login.service';
3
import createHTTPClient from 'src/core/factory/http.factory';
4
5
function getStoreApiService(client = null, loginService = null) {
6
    if (client === null) {
7
        client = createHTTPClient();
8
    }
9
10
    if (loginService === null) {
11
        loginService = createLoginService(client, Shopware.Context.api);
0 ignored issues
show
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12
    }
13
14
    return new StoreApiService(client, loginService);
15
}
16
17
describe('storeService', () => {
18
    it('is registered correctly', () => {
19
        expect(getStoreApiService()).toBeInstanceOf(StoreApiService);
20
    });
21
22
    it('handles plugin download and update with corresponding requests', () => {
23
        const client = createHTTPClient();
24
25
        const getMethod = jest.spyOn(client, 'get').mockImplementation(() => Promise.resolve());
0 ignored issues
show
The variable jest seems to be never declared. If this is a global, consider adding a /** global: jest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
26
        const postMethod = jest.spyOn(client, 'post').mockImplementation(() => Promise.resolve());
27
28
        const storeApiService = getStoreApiService(client, null);
29
30
        storeApiService.downloadPlugin('not-null', true);
31
32
        expect(getMethod).toHaveBeenCalledTimes(1);
33
34
        if (Shopware.Feature.isActive('FEATURE_NEXT_12957')) {
0 ignored issues
show
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
35
            expect(postMethod).toHaveBeenCalledWith('/_action/plugin/update');
36
        }
37
    });
38
});
39