Skip to content

Commit

Permalink
add integration test for spread operator
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Feb 24, 2018
1 parent 39438c7 commit b0949cb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/cases/parsing/spread/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "ok";
11 changes: 11 additions & 0 deletions test/cases/parsing/spread/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import X, { A, B } from "./module";
import * as M from "./module";

it("should support spread operator", function() {
var o1 = { ...X };
o1.should.be.eql({ A: "A", B: "B" });
var o2 = { ...({ X }) };
o2.should.be.eql({ X: { A: "A", B: "B" } });
var o3 = { ...M };
o3.should.be.eql({ default: { A: "A", B: "B" }, A: "A", B: "B" });
});
6 changes: 6 additions & 0 deletions test/cases/parsing/spread/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const A = "A";
const B = "B";

export default { A, B };

export { A, B };
5 changes: 5 additions & 0 deletions test/cases/parsing/spread/test.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var supportsSpread = require("../../../helpers/supportsSpread");

module.exports = function(config) {
return supportsSpread();
};
9 changes: 9 additions & 0 deletions test/helpers/supportsSpread.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function supportsSpread() {
try {
var x = { a: true }, y; // eslint-disable-line no-unused-vars
eval("y = { ...x }");
return y !== x && y.a;
} catch(e) {
return false;
}
};

0 comments on commit b0949cb

Please sign in to comment.