-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from kintone-labs/SSR-3283_AddUnitTest_review
SSR-3283: review AddUnitTest
- Loading branch information
Showing
8 changed files
with
106 additions
and
112 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { describe, expect, jest, test } from '@jest/globals'; | ||
import { Command } from 'commander'; | ||
import { readFileSync, writeFileSync } from 'jsonfile'; | ||
import { devCommandHandle } from '../devCommand'; | ||
import { WRITE_FILE_OPTIONS } from '../../../constant'; | ||
import { | ||
dataInitDevCommand, | ||
dataTest, | ||
devCommandInit | ||
} from './uploadConfig.test'; | ||
|
||
describe('Dev command', () => { | ||
describe('Watch', () => { | ||
let mainProgram: Command; | ||
const readLineAsyncParam = jest.fn(); | ||
|
||
test('Should be "" when setting the value watch to false', async () => { | ||
const currentDir = await devCommandInit('Plugin'); | ||
const config = readFileSync(`${currentDir}/config.json`); | ||
config.uploadConfig.desktop.css = dataTest(); | ||
config.uploadConfig.mobile.js = dataTest(); | ||
Object.assign(config.uploadConfig, { | ||
config: { css: dataTest(), js: dataTest() } | ||
}); | ||
|
||
writeFileSync(`${currentDir}/config.json`, config, WRITE_FILE_OPTIONS); | ||
const { webpackDevServer, commandConfig, responseMessage } = | ||
dataInitDevCommand({ process, watch: false }); | ||
|
||
try { | ||
await devCommandHandle({ | ||
ws: webpackDevServer, | ||
cmd: commandConfig, | ||
data: responseMessage, | ||
readLineAsyncParam | ||
}); | ||
expect(mainProgram.opts().appName).toEqual(''); | ||
} catch (error) { | ||
expect(error).toEqual(error); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { describe, expect, test } from '@jest/globals'; | ||
import { generateAppFolder } from '../generator'; | ||
import { AppOption } from '../../../dto/app'; | ||
import { | ||
createTemplateWithArgv, | ||
getRandomProjectName, | ||
initProject | ||
} from '../../../../unit_test/helper'; | ||
import { APP_NAME, DIR_BUILD_PATH } from '../../../../unit_test/constant'; | ||
|
||
const initializeTestProject = async (initProjectType: any = initProject) => { | ||
const projectName = getRandomProjectName(); | ||
const currentDir = `${DIR_BUILD_PATH}/${projectName}`; | ||
await initProjectType(DIR_BUILD_PATH, projectName); | ||
const argv = [ | ||
'node', | ||
'dist', | ||
'create-template', | ||
'--quick', | ||
'--app-name', | ||
APP_NAME, | ||
'--app-id', | ||
'100' | ||
]; | ||
await createTemplateWithArgv(projectName, argv); | ||
|
||
return { projectName, currentDir }; | ||
}; | ||
|
||
describe('Initialize command', () => { | ||
const appOption = { | ||
appName: APP_NAME, | ||
type: 'Customization', | ||
appID: '100', | ||
scope: 'ALL' | ||
} as unknown as AppOption; | ||
|
||
describe('App Folder', () => { | ||
test('Should create a folder when the app option is set correctly', async () => { | ||
await initializeTestProject(); | ||
appOption.setAuth = true; | ||
appOption.appName = 'test-app-1'; | ||
appOption.useCybozuLint = true; | ||
const creationSuccessful = generateAppFolder(appOption); | ||
|
||
expect(creationSuccessful).toBe(false); | ||
}); | ||
|
||
test('Should display "App folder existed." when the app name already exists', async () => { | ||
appOption.useCybozuLint = true; | ||
appOption.appName = 'test-app-1'; | ||
const errorMessage = generateAppFolder(appOption); | ||
|
||
expect(errorMessage).toBe('App folder existed.'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters