mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(distribute) add ability to import config from remote export server
This commit is contained in:
parent
b8e4f9659a
commit
2ad2fc4023
20 changed files with 856 additions and 22 deletions
54
common/datetime.spec.js
Normal file
54
common/datetime.spec.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const sinon = require('sinon');
|
||||
|
||||
const datetime = require('./datetime');
|
||||
|
||||
test('common: datetime', (t) => {
|
||||
const dateStr = 'Fri, 17 Aug 2018 10:56:48';
|
||||
const result = datetime(new Date(dateStr));
|
||||
|
||||
const expected = '2018.08.17 10:56:48';
|
||||
|
||||
t.equals(result, expected, 'should equal');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('common: datetime: no arg', (t) => {
|
||||
const {Date} = global;
|
||||
|
||||
let called = false;
|
||||
const myDate = class extends Date {
|
||||
constructor() {
|
||||
super();
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
||||
global.Date = myDate;
|
||||
|
||||
datetime();
|
||||
|
||||
global.Date = Date;
|
||||
t.ok(called, 'should call new Date');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('common: 0 before number', (t) => {
|
||||
const dateStr = 'Fri, 17 Aug 2018 10:56:08';
|
||||
const result = datetime(new Date(dateStr));
|
||||
|
||||
const expected = '2018.08.17 10:56:08';
|
||||
|
||||
t.equals(result, expected, 'should equal');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('common: datetime: wrong args', (t) => {
|
||||
const fn = () => datetime({});
|
||||
|
||||
t.throws(fn, /date should be instanceof Date!/, 'should throw');
|
||||
t.end();
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue