2020-08-29 07:14:49 +03:00
|
|
|
import { mark, extract, refer } from '../src/helpers';
|
2020-08-06 23:39:05 +03:00
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
describe('Helpers', function () {
|
|
|
|
it('mark', function () {
|
2020-08-06 23:39:05 +03:00
|
|
|
expect(mark({ testData: 'test' }, 'testType')).toMatchSnapshot();
|
|
|
|
expect(
|
|
|
|
mark({ testData: 'test' }, 'testType', 'toString')
|
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
it('extract', function () {
|
2020-08-06 23:39:05 +03:00
|
|
|
expect(extract({ testData: 'test' }, 'testType')).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
it('refer', function () {
|
2020-08-29 07:14:49 +03:00
|
|
|
const TestClass = function (data: unknown) {
|
2020-08-06 23:39:05 +03:00
|
|
|
return data;
|
|
|
|
};
|
2021-10-21 22:08:35 +03:00
|
|
|
const testInstance = new (TestClass as any)({
|
|
|
|
testData: 'test',
|
|
|
|
}) as unknown;
|
2020-08-06 23:39:05 +03:00
|
|
|
expect(
|
2020-08-29 07:14:49 +03:00
|
|
|
refer(testInstance, 'testType', false, [TestClass as any])
|
2020-08-06 23:39:05 +03:00
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|