Skip to content

Commit b0949cb

Browse files
committed
add integration test for spread operator
1 parent 39438c7 commit b0949cb

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

test/cases/parsing/spread/a.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "ok";

test/cases/parsing/spread/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import X, { A, B } from "./module";
2+
import * as M from "./module";
3+
4+
it("should support spread operator", function() {
5+
var o1 = { ...X };
6+
o1.should.be.eql({ A: "A", B: "B" });
7+
var o2 = { ...({ X }) };
8+
o2.should.be.eql({ X: { A: "A", B: "B" } });
9+
var o3 = { ...M };
10+
o3.should.be.eql({ default: { A: "A", B: "B" }, A: "A", B: "B" });
11+
});

test/cases/parsing/spread/module.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const A = "A";
2+
const B = "B";
3+
4+
export default { A, B };
5+
6+
export { A, B };
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var supportsSpread = require("../../../helpers/supportsSpread");
2+
3+
module.exports = function(config) {
4+
return supportsSpread();
5+
};

test/helpers/supportsSpread.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = function supportsSpread() {
2+
try {
3+
var x = { a: true }, y; // eslint-disable-line no-unused-vars
4+
eval("y = { ...x }");
5+
return y !== x && y.a;
6+
} catch(e) {
7+
return false;
8+
}
9+
};

0 commit comments

Comments
 (0)