mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(cloudfunc) clear-module -> mock-require
This commit is contained in:
parent
52ffc2ac28
commit
e18ddb2e18
1 changed files with 5 additions and 10 deletions
|
|
@ -15,16 +15,11 @@ const CloudFuncPath = COMMONDIR + 'cloudfunc';
|
|||
|
||||
const CloudFunc = require(CloudFuncPath);
|
||||
|
||||
const readFilesSync = require('@cloudcmd/read-files-sync');
|
||||
|
||||
const test = require('tape');
|
||||
const clean = require('clear-module');
|
||||
const fresh = (name) => {
|
||||
clean(name);
|
||||
return require(name);
|
||||
};
|
||||
const {reRequire} = require('mock-require');
|
||||
|
||||
const htmlLooksLike = require('html-looks-like');
|
||||
const readFilesSync = require('@cloudcmd/read-files-sync');
|
||||
|
||||
const FS_DIR = TMPLDIR + 'fs/';
|
||||
const EXPECT_PATH = __dirname + '/cloudfunc.html';
|
||||
|
|
@ -139,7 +134,7 @@ test('cloudfunc: formatMsg', (t) => {
|
|||
});
|
||||
|
||||
test('cloudfunc: getTitle', (t) => {
|
||||
const CloudFunc = fresh(CloudFuncPath);
|
||||
const CloudFunc = reRequire(CloudFuncPath);
|
||||
|
||||
const result = CloudFunc.getTitle();
|
||||
|
||||
|
|
@ -148,7 +143,7 @@ test('cloudfunc: getTitle', (t) => {
|
|||
});
|
||||
|
||||
test('cloudfunc: getTitle: no name', (t) => {
|
||||
const CloudFunc = fresh(CloudFuncPath);
|
||||
const CloudFunc = reRequire(CloudFuncPath);
|
||||
const path = '/hello/world';
|
||||
|
||||
const result = CloudFunc.getTitle({
|
||||
|
|
@ -160,7 +155,7 @@ test('cloudfunc: getTitle: no name', (t) => {
|
|||
});
|
||||
|
||||
test('cloudfunc: getTitle: name, path', (t) => {
|
||||
const CloudFunc = fresh(CloudFuncPath);
|
||||
const CloudFunc = reRequire(CloudFuncPath);
|
||||
const name = 'hello';
|
||||
const path = '/hello/world';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue