Last active
April 7, 2021 23:52
-
-
Save dexfs/4128cfbba4c61f31c09fb784abb8c1df to your computer and use it in GitHub Desktop.
Utilizando cloneDeep pois o javascript utliza shallow copy (copiando apenas o primeiro nível do objeto), spread e Object.assign() fazem dessa forma, o que tiver nested é passado por referência.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| name: "name", | |
| nested: { | |
| email: 'user@domain.com.br', | |
| name: 'fulano de tal', | |
| }, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Sut = require('@source/index') | |
| const mock = require('./mocks/base-individual-quotation') | |
| const cloneDeep = require('lodash.clonedeep'); | |
| describe('Testando', () => { | |
| it('should be defined', async () => { | |
| const sut = new Sut() | |
| expect(sut).toBeDefined() | |
| }) | |
| it('should', async () => { | |
| const params = cloneDeep(mock) | |
| const sut = new Sut() | |
| sut.update(params) | |
| }) | |
| it('should2', async () => { | |
| const params = cloneDeep(mock) | |
| console.log('params2', params) | |
| const sut = new Sut() | |
| sut.update(params) | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Test { | |
| update(params) { | |
| params.name = 'teste' | |
| params.nested.name = 'olá ô loquinho' | |
| } | |
| } | |
| module.exports = Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment