Skip to content

Commit

Permalink
Adjusting account tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaegerfe committed Sep 19, 2023
1 parent aa42a01 commit fdbf1d1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/jest/__tests__/store/account/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ global.fetch = jest.fn((input: RequestInfo | URL) =>
} as unknown as Response),
);

const sessionStorageMock = {
const localStorageMock = {
getItem: jest.fn(),
setItem: jest.fn(),
removeItem:jest.fn(),
};
Object.defineProperty(window, 'sessionStorage', { value: sessionStorageMock });
Object.defineProperty(window, 'localStorage', { value: localStorageMock });


const transactionHeaders = {
Expand Down Expand Up @@ -98,6 +98,7 @@ describe('Store - Account Actions', () => {
shouldRequestAccountName: jest.fn().mockResolvedValue(new Promise(resolve => resolve(requestName))),
login: jest.fn().mockResolvedValue(new Promise(resolve => resolve(users))),
getName: jest.fn().mockReturnValue('autoLogin'),
chains: [{chainId: "1" }]

Check failure on line 101 in test/jest/__tests__/store/account/actions.spec.ts

View workflow job for this annotation

GitHub Actions / tests

A space is required after '{'

Check failure on line 101 in test/jest/__tests__/store/account/actions.spec.ts

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote

Check failure on line 101 in test/jest/__tests__/store/account/actions.spec.ts

View workflow job for this annotation

GitHub Actions / tests

Missing trailing comma
});
let authenticator = newAuthenticatorMock();

Expand All @@ -116,6 +117,7 @@ describe('Store - Account Actions', () => {
user: null,
accountName: '',
accountPermission: '',
chainId: "1",

Check failure on line 120 in test/jest/__tests__/store/account/actions.spec.ts

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
} as AccountStateInterface;

});
Expand Down Expand Up @@ -162,8 +164,8 @@ describe('Store - Account Actions', () => {
expect(commit).toHaveBeenCalledWith('setUser', expect.any(FuelUserWrapper));
expect(commit).toHaveBeenCalledWith('setIsAuthenticated', true);
expect(commit).toHaveBeenCalledWith('setAccountName', 'john.doe');
expect(sessionStorageMock.setItem).toHaveBeenCalledWith('account', 'john.doe');
expect(sessionStorageMock.setItem).toHaveBeenCalledWith('autoLogin', 'autoLogin');
expect(localStorageMock.setItem).toHaveBeenCalledWith('account_1', 'john.doe');
expect(localStorageMock.setItem).toHaveBeenCalledWith('autoLogin_1', 'autoLogin');

});

Expand All @@ -183,8 +185,8 @@ describe('Store - Account Actions', () => {
expect(commit).toHaveBeenCalledWith('setUser', expect.any(FuelUserWrapper));
expect(commit).toHaveBeenCalledWith('setIsAuthenticated', true);
expect(commit).toHaveBeenCalledWith('setAccountName', 'john.doe');
expect(sessionStorageMock.setItem).toHaveBeenCalledWith('account', 'john.doe');
expect(sessionStorageMock.setItem).toHaveBeenCalledWith('autoLogin', 'autoLogin');
expect(localStorageMock.setItem).toHaveBeenCalledWith('account_1', 'john.doe');
expect(localStorageMock.setItem).toHaveBeenCalledWith('autoLogin_1', 'autoLogin');
});

});
Expand All @@ -199,8 +201,8 @@ describe('Store - Account Actions', () => {
expect(commit).toHaveBeenCalledWith('setAccountName', '');
expect(commit).toHaveBeenCalledWith('setUser', null);

expect(sessionStorageMock.removeItem).toHaveBeenCalledWith('account');
expect(sessionStorageMock.removeItem).toHaveBeenCalledWith('autoLogin');
expect(localStorageMock.removeItem).toHaveBeenCalledWith('account_1');
expect(localStorageMock.removeItem).toHaveBeenCalledWith('autoLogin_1');
});
});
});
Expand Down

0 comments on commit fdbf1d1

Please sign in to comment.