khcanvas_test.js 1.11 KB
//@ts-check
//https://github.com/gatoona/AWS-Selenium
import * as canvas from '../khcanvas.js'
import * as rd from 'readline'
import * as mocha from 'mocha'
import process from 'node:process';
import util from 'util'
import { rejects } from 'assert';


mocha.describe('khcanvas', () => {
    mocha.it('opening selenium', async () => {
        await canvas.using_selenium(async (driver) => {
            await driver.get("http://khuhub.khu.ac.kr");
            await driver.getTitle().then( (title) => {
                console.log(title);
            });
        });
    })
});


mocha.describe('khcanvas', () => {
    mocha.it('get schedule', async () => {
        const rl = rd.createInterface({
            input: process.stdin,
            output: process.stdout
        })

        const question = util.promisify(rl.question).bind(rl);

        const a = await question('a');
        const b = await question('b');

        return await canvas.get_schedule(a, b, new Date())
            .then(it => console.log(it))
            .catch(it => {
                console.log(it)
                rejects(it)
            })
    })
});