From fde6f36f3cef1739036955051c9ba7697b4c007b Mon Sep 17 00:00:00 2001 From: Arturo Riveron Borodovisina Date: Thu, 10 Mar 2022 14:41:37 +0100 Subject: [PATCH] test(decorators): increase unit test coverage --- test/tests/decorators.js | 25 +++++++++++++++++++++++++ test/tests/index.js | 1 + 2 files changed, 26 insertions(+) create mode 100644 test/tests/decorators.js diff --git a/test/tests/decorators.js b/test/tests/decorators.js new file mode 100644 index 00000000..0adeb69f --- /dev/null +++ b/test/tests/decorators.js @@ -0,0 +1,25 @@ +/* @flow */ + +import { memoized, promise } from '../../src/decorators'; + +describe('decorators cases', () => { + it('memoized', () => { + const descriptor = { value: () => 1 }; + memoized({ }, 'value', descriptor); + const resultValue = descriptor.value(); + + if (resultValue !== 1) { + throw new Error(`memoized function should return the value "1", but got: ${ resultValue }`); + } + }); + + it('promise', async () => { + const descriptor = { value: () => 1 }; + promise({ }, 'value', descriptor); + const resultValue = await descriptor.value(); + + if (resultValue !== 1) { + throw new TypeError(`promise function should return the value "1", but got: ${ resultValue }`); + } + }); +}); \ No newline at end of file diff --git a/test/tests/index.js b/test/tests/index.js index ec8e7b1f..64745aea 100644 --- a/test/tests/index.js +++ b/test/tests/index.js @@ -6,3 +6,4 @@ import './css'; import './experiment'; import './global'; import './device'; +import './decorators';