Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Apr 28, 2017
1 parent b17a65a commit 0d9f689
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions integration_tests/snapshot-serializers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"jest": {
"testEnvironment": "node",
"transform": {
"^.+\\.js$": "<rootDir>/transformer.js"
},
"snapshotSerializers": [
"./plugins/foo",
"<rootDir>/plugins/bar"
Expand Down
5 changes: 4 additions & 1 deletion integration_tests/snapshot-serializers/plugins/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
*/
'use strict';

/* eslint-disable no-unused-vars */

const createPlugin = require('../utils').createPlugin;
module.exports = createPlugin('bar');

// We inject the call to "createPlugin('bar') through the transformer"
18 changes: 18 additions & 0 deletions integration_tests/snapshot-serializers/transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

module.exports = {
process(src, filename, config, options) {
if (/plugins\/bar/.test(filename)) {
return `${src};\module.exports = createPlugin('bar');`;
}
return src;
},
};
2 changes: 1 addition & 1 deletion integration_tests/snapshot-serializers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

exports.createPlugin = prop => {
return {
print: (val, serialize) => `${prop}: ${serialize(val[prop])}`,
print: (val, serialize) => `${prop} - ${serialize(val[prop])}`,
test: val => val && val.hasOwnProperty(prop),
};
};

0 comments on commit 0d9f689

Please sign in to comment.