diff --git a/src/config-parser.test.js b/src/config-parser.test.js index 1789b57..03c7695 100644 --- a/src/config-parser.test.js +++ b/src/config-parser.test.js @@ -97,11 +97,13 @@ const cases = [ source: 'const config = {}; export default config', expected: 'const config = { property: "value"}; export default config' }, + // with more than 1 declaration chained together { property: 'property', - source: 'var config = {}; export default config', - expected: 'var config = { property: "value"}; export default config' + source: 'var temp = {}, config = {}; export default config', + expected: 'var temp = {}, config = { property: "value"}; export default config' }, + // deeper { property: 'a.b.c', source: 'var config = {}; export default config', @@ -140,11 +142,13 @@ const cases = [ source: 'const config = {}; module.exports = config', expected: 'const config = { property: "value"}; module.exports = config' }, + // with more than 1 declaration chained together { property: 'property', - source: 'var config = {}; module.exports = config', - expected: 'var config = { property: "value"}; module.exports = config' + source: 'var temp = {}, config = {}; module.exports = config', + expected: 'var temp = {}, config = { property: "value"}; module.exports = config' }, + // deeper { property: 'a.b.c', source: 'var config = {}; module.exports = config', @@ -187,6 +191,15 @@ const cases = [ 'import { defineConfig } from "astro/config"; const config = defineConfig({ property: "value" }); export default config', allowWrappingCall: true }, + // with more than 1 declaration chained together + { + property: 'property', + source: + 'import { defineConfig } from "astro/config"; const temp = {}, config = defineConfig({}); export default config', + expected: + 'import { defineConfig } from "astro/config"; const temp = {}, config = defineConfig({ property: "value" }); export default config', + allowWrappingCall: true + }, // // Indirect default export with wrapping call at the export @@ -198,6 +211,15 @@ const cases = [ 'import { defineConfig } from "astro/config"; const config = { property: "value" }; export default defineConfig(config)', allowWrappingCall: true }, + // with more than 1 declaration chained together + { + property: 'property', + source: + 'import { defineConfig } from "astro/config"; const temp = {}, config = {}; export default defineConfig(config)', + expected: + 'import { defineConfig } from "astro/config"; const temp = {}, config = { property: "value" }; export default defineConfig(config)', + allowWrappingCall: true + }, // // Indirect module exports with wrapping call at the definition @@ -210,6 +232,15 @@ const cases = [ 'const { defineConfig } = require("astro/config"); const config = defineConfig({ property: "value"}); module.exports = config', allowWrappingCall: true }, + // with more than 1 declaration chained together + { + property: 'property', + source: + 'const { defineConfig } = require("astro/config"); const temp = {}, config = defineConfig({}); module.exports = config', + expected: + 'const { defineConfig } = require("astro/config"); const temp = {}, config = defineConfig({ property: "value"}); module.exports = config', + allowWrappingCall: true + }, // // Indirect module exports with wrapping call at the export @@ -221,6 +252,15 @@ const cases = [ expected: 'const { defineConfig } = require("astro/config"); const config = { property: "value"}; module.exports = defineConfig(config)', allowWrappingCall: true + }, + // with more than 1 declaration chained together + { + property: 'property', + source: + 'const { defineConfig } = require("astro/config"); const temp = {}, config = {}; module.exports = defineConfig(config)', + expected: + 'const { defineConfig } = require("astro/config"); const temp = {}, config = { property: "value"}; module.exports = defineConfig(config)', + allowWrappingCall: true } ]