From 85c0c75632fdd340afef83323b3ce529ea260c3e Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sat, 21 Oct 2023 20:16:15 +0100 Subject: [PATCH] test: optimize split params --- test/generate-esm.test.js | 2 +- test/generate-plugin.test.js | 2 +- test/generate-typescript-esm.test.js | 2 +- test/generate-typescript.test.js | 2 +- test/generate.test.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/generate-esm.test.js b/test/generate-esm.test.js index 11d2953e..46ded3a4 100644 --- a/test/generate-esm.test.js +++ b/test/generate-esm.test.js @@ -180,7 +180,7 @@ function define (t) { // Test for "type:module" t.equal(pkg.type, 'module') - const testGlob = pkg.scripts.test.split(' ')[2].replace(/"/g, '') + const testGlob = pkg.scripts.test.split(' ', 3)[2].replace(/"/g, '') t.equal(minimatch.match(['test/services/plugins/more/test/here/ok.test.js'], testGlob).length, 1) resolve() }) diff --git a/test/generate-plugin.test.js b/test/generate-plugin.test.js index b655e717..61c8255c 100644 --- a/test/generate-plugin.test.js +++ b/test/generate-plugin.test.js @@ -139,7 +139,7 @@ function define (t) { t.equal(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript) t.same(pkg.tsd, pluginTemplate.tsd) - const testGlob = pkg.scripts.unit.split(' ')[1].replace(/"/g, '') + const testGlob = pkg.scripts.unit.split(' ', 2)[1].replace(/"/g, '') t.equal(minimatch.match(['test/more/test/here/ok.test.js'], testGlob).length, 1) resolve() }) diff --git a/test/generate-typescript-esm.test.js b/test/generate-typescript-esm.test.js index 9115a38e..05e99b85 100644 --- a/test/generate-typescript-esm.test.js +++ b/test/generate-typescript-esm.test.js @@ -143,7 +143,7 @@ function define (t) { t.equal(pkg.devDependencies.tap, cliPkg.devDependencies.tap) t.equal(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript) - const testGlob = pkg.scripts.test.split(' ')[10].replace(/"/g, '') + const testGlob = pkg.scripts.test.split(' ', 11)[10].replace(/"/g, '') t.equal(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1) resolve() diff --git a/test/generate-typescript.test.js b/test/generate-typescript.test.js index 987b8868..c2e8e4e3 100644 --- a/test/generate-typescript.test.js +++ b/test/generate-typescript.test.js @@ -143,7 +143,7 @@ function define (t) { t.equal(pkg.devDependencies.tap, cliPkg.devDependencies.tap) t.equal(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript) - const testGlob = pkg.scripts.test.split(' ')[10].replace(/"/g, '') + const testGlob = pkg.scripts.test.split(' ', 11)[10].replace(/"/g, '') t.equal(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1) resolve() diff --git a/test/generate.test.js b/test/generate.test.js index e71141e8..463aba4e 100644 --- a/test/generate.test.js +++ b/test/generate.test.js @@ -170,7 +170,7 @@ function define (t) { t.equal(pkg.dependencies['@fastify/sensible'], cliPkg.devDependencies['@fastify/sensible']) t.equal(pkg.devDependencies.tap, cliPkg.devDependencies.tap) - const testGlob = pkg.scripts.test.split(' ')[1].replace(/"/g, '') + const testGlob = pkg.scripts.test.split(' ', 2)[1].replace(/"/g, '') t.equal(minimatch.match(['test/services/plugins/more/test/here/ok.test.js'], testGlob).length, 1) resolve() })