mirror of https://github.com/rancher/dashboard.git
Add test for resource class
This commit is contained in:
parent
47dcfda5d7
commit
03dba9f064
|
|
@ -0,0 +1,46 @@
|
||||||
|
import Resource from '@shell/plugins/dashboard-store/resource-class.js';
|
||||||
|
|
||||||
|
describe('class: Resource', () => {
|
||||||
|
describe('given custom resource keys', () => {
|
||||||
|
const customResource = {
|
||||||
|
__rehydrate: 'whatever',
|
||||||
|
__clone: 'whatever',
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should keep internal keys', () => {
|
||||||
|
const resource = new Resource(customResource, {
|
||||||
|
getters: { schemaFor: () => ({ linkFor: jest.fn() }) },
|
||||||
|
dispatch: jest.fn(),
|
||||||
|
rootGetters: { 'i18n/t': jest.fn() },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect({ ...resource }).toStrictEqual(customResource);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('method: save', () => {
|
||||||
|
/**
|
||||||
|
* DISCLAIMER ***************************************************************************************
|
||||||
|
* Logs are prevented to avoid polluting the test output.
|
||||||
|
****************************************************************************************************
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line jest/no-hooks
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.spyOn(console, 'warn').mockImplementation(() => { });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove all the internal keys', async() => {
|
||||||
|
const resource = new Resource(customResource, {
|
||||||
|
getters: { schemaFor: () => ({ linkFor: jest.fn() }) },
|
||||||
|
dispatch: jest.fn(),
|
||||||
|
rootGetters: { 'i18n/t': jest.fn() },
|
||||||
|
});
|
||||||
|
|
||||||
|
const expectation = {};
|
||||||
|
|
||||||
|
await resource.save();
|
||||||
|
|
||||||
|
expect({ ...resource }).toStrictEqual(expectation);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue