Last active
          December 1, 2017 23:04 
        
      - 
      
- 
        Save eschwartz/1c0ef2cd4a83362049636b5fb3e63039 to your computer and use it in GitHub Desktop. 
    assert-partial.js
  
        
  
    
      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
    
  
  
    
  | import * as assert from 'assert'; | |
| function assertPartial(actualObj:any, expectedPartial: any, msg?:string) { | |
| const actualPartial:any = Object.keys(expectedPartial) | |
| .reduce((part, key) => ({ | |
| ...part, | |
| [key]: actualPartial[key] | |
| }), {}); | |
| assert.deepStrictEqual(actualPartial, expectedPartial, msg); | |
| } | |
| export default assertPartial; | 
  
    
      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 assert = require('assert'); | |
| const _ = require('lodash'); | |
| /** | |
| * @name partial | |
| * @memberof assert | |
| * | |
| * @param {Object} actualObj | |
| * @param {Object} expectedPartial | |
| * @param {string} msg | |
| */ | |
| function assertPartial(actualObj, expectedPartial, msg) { | |
| const actualPartial = _.pick(actualObj, _.keys(expectedPartial)); | |
| assert.deepStrictEqual(actualPartial, expectedPartial, msg); | |
| } | |
| module.exports = assertPartial; | 
  
    
      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
    
  
  
    
  | import * as _ from 'lodash'; | |
| import * as assert from 'assert'; | |
| function assertPartial(actualObj:any, expectedPartial: any, msg?:string) { | |
| const actualPartial = _.pick(actualObj, _.keys(expectedPartial)); | |
| assert.deepStrictEqual(actualPartial, expectedPartial, msg); | |
| } | |
| export default assertPartial; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment