diff --git a/jest.config.js b/jest.config.js index 9dfb169..935f21c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,6 +4,6 @@ module.exports = { collectCoverageFrom: ['/src/**/*.js'], coverageDirectory: 'coverage', testEnvironment: 'node', - testMatch: ['/tests/**/*.test.js'], + testMatch: ['/tests/**/*.test.js', '/src/**/*.test.js'], verbose: true, } diff --git a/src/infrastructure/boxen.test.js b/src/infrastructure/boxen.test.js new file mode 100644 index 0000000..10e6a92 --- /dev/null +++ b/src/infrastructure/boxen.test.js @@ -0,0 +1,34 @@ +const boxen = require('boxen') +const { greenBox } = require('./boxen') + +jest.mock('boxen') +beforeEach(boxen.mockReset) + +test('Should call boxen with basic settings and return boxen content', async () => { + boxen.mockReturnValue('MOCKED VALUE') + + const input = 'sample input' + const greenBoxConfig = { + padding: 1, + borderStyle: 'double', + borderColor: 'green', + } + + const result = greenBox(input) + + const boxenMockFirstCall = boxen.mock.calls[0] + + expect(boxenMockFirstCall[0]).toEqual(input) + expect(boxenMockFirstCall[1]).toMatchObject(greenBoxConfig) + + expect(result).toEqual('MOCKED VALUE') +}) + +test('Should add margin if config is passed', () => { + boxen.mockReturnValue('MOCKED VALUE') + + greenBox('some input', { margin: 4 }) + + const boxenMockFirstCall = boxen.mock.calls[0] + expect(boxenMockFirstCall[1]).toMatchObject({ margin: 4 }) +})