review comments

This commit is contained in:
Marcus Eide
2020-02-20 14:59:47 +01:00
parent 5b539a3e14
commit 2d27436129
2 changed files with 8 additions and 6 deletions
+3 -3
View File
@@ -14,6 +14,7 @@
"devDependencies": {
"@spotify/web-scripts": "^6.0.0",
"@types/node": "^13.7.2",
"@types/inquirer": "^6.5.0",
"nodemon": "^2.0.2",
"ts-node": "^8.6.2"
},
@@ -21,12 +22,11 @@
"backstage-cli": "bin/backstage-cli"
},
"dependencies": {
"@types/inquirer": "^6.5.0",
"commander": "^4.1.1",
"dashify": "^2.0.0",
"handlebars": "^4.7.3",
"inquirer": "^7.0.4",
"replace-in-file": "^5.0.2"
"replace-in-file": "^5.0.2",
"inquirer": "^7.0.4"
},
"files": [
"templates",
@@ -1,21 +1,23 @@
import fs from 'fs';
import path from 'path';
import os from 'os';
import { createPluginFolder, createFileFromTemplate } from './createPlugin';
describe('createPlugin', () => {
describe('createPluginFolder', () => {
it('should create a plugin directory in the correct place', () => {
const tempDir = fs.mkdtempSync('createPluginTest');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-'));
try {
const pluginFolder = createPluginFolder(tempDir, 'foo');
expect(fs.existsSync(pluginFolder)).toBe(true);
expect(pluginFolder).toMatch(/packages\/plugins\/foo/);
} finally {
fs.rmdirSync(tempDir, { recursive: true });
}
});
it('should not create a plugin directory if it already exists', () => {
const tempDir = fs.mkdtempSync('createPluginTest');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-'));
try {
const pluginFolder = createPluginFolder(tempDir, 'foo');
expect(fs.existsSync(pluginFolder)).toBe(true);
@@ -30,7 +32,7 @@ describe('createPlugin', () => {
describe('createFileFromTemplate', () => {
it('should generate a valid output with inserted values', () => {
const tempDir = fs.mkdtempSync('createFileFromTemplate');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-'));
try {
const sourceData = '{"name": "@spotify-backstage/{{id}}"}';
const targetData = '{"name": "@spotify-backstage/foo"}';