diff --git a/miscservices/TimeTest_js/src/main/js/default/test/Time.test.js b/miscservices/TimeTest_js/src/main/js/default/test/Time.test.js index e1f9fc599029b4879a4852c2022197dbcbc8902c..9485271cc1b659b9dd8d282d4a64bc119ac30247 100755 --- a/miscservices/TimeTest_js/src/main/js/default/test/Time.test.js +++ b/miscservices/TimeTest_js/src/main/js/default/test/Time.test.js @@ -17,8 +17,9 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import systemTime from '@ohos.systemTime' -describe('TimeTest', function() { +describe('TimeTest', function(){ console.log('start################################start'); + /** * @tc.number SUB_systemTime_setTime_JS_API_0100 * @tc.name Test systemTime.setTime @@ -103,4 +104,122 @@ describe('TimeTest', function() { console.log('SUB_systemTime_setTime_JS_API_0400 end'); done() }) + + /** + * @tc.number SUB_systemTime_setDate_JS_API_0100 + * @tc.name Test systemTime.setDate Invalid value + * @tc.desc Test systemTime_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setDate_test1', 0, async function (done) { + console.log("SUB_systemTime_setDate_JS_API_0100 start"); + var data = new Date("October 13, 2020 11:13:00"); + systemTime.setDate(-1).then(data => { + console.log("setTime ===data " + data); + done(); + }).catch(error => { + console.log("setTime ===error " + error); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setDate_JS_API_0200 + * @tc.name Test systemTime.setDate Invalid value + * @tc.desc Test systemTime_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setDate_test2', 0, async function (done) { + console.log("SUB_systemTime_setDate_JS_API_0200 start"); + systemTime.setDate(0).then(data => { + console.log("setTime ===data " + data); + done(); + }).catch(error => { + console.log("setTime ===error " + error); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setDate_JS_API_0300 + * @tc.name Test systemTime.setDate Invalid value + * @tc.desc Test systemTime_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setDate_test3', 0, async function (done) { + console.log("SUB_systemTime_setDate_JS_API_0300 start"); + var data = new Date("October 13, 2020 11:13:00"); + systemTime.setDate(data, (error, data) => { + if(error){ + console.log("setTime ===error " + error); + done(); + }else{ + console.log("setTime ===data " + data); + done(); + } + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0100 + * @tc.name Test systemTime.setTimezone Invalid value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setTimezone_test1', 0, async function (done) { + console.log("SUB_systemTime_setTimezone_JS_API_0100 start"); + systemTime.setTimezone('Asia, Shanghai').then(data => { + console.log("setTime ===data " + data) + done(); + }).catch(error => { + console.log("setTime ===error " + error) + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0200 + * @tc.name Test systemTime.setTimezone Invalid value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setTimezone_test1', 0, async function (done) { + console.log("SUB_systemTime_setTimezone_JS_API_0100 start"); + systemTime.setTimezone('Beijing,China').then(data => { + console.log("setTime ===data " + data) + done(); + }).catch(error => { + console.log("setTime ===error " + error) + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0300 + * @tc.name Test systemTime.setTimezone Invalid value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setTimezone_test1', 0, async function (done) { + console.log("SUB_systemTime_setTimezone_JS_API_0100 start"); + systemTime.setTimezone('Baker Island, U.S.A.').then(data => { + console.log("setTime ===data " + data) + done(); + }).catch(error => { + console.log("setTime ===error " + error) + done(); + }); + }); })