medium/test/test.ts

48 lines
1.4 KiB
TypeScript
Raw Normal View History

import { expect, tap } from '@push.rocks/tapbundle';
import * as medium from '../ts/index.js';
2020-11-16 01:37:00 +00:00
import {Qenv} from '@push.rocks/qenv';
2020-11-16 03:15:49 +00:00
const testQenv = new Qenv('./', './.nogit/');
let testMediumAccount: medium.MediumAccount;
2020-11-16 01:37:00 +00:00
tap.test('first test', async () => {
testMediumAccount = new medium.MediumAccount(await testQenv.getEnvVarOnDemand('MEDIUM_API_TOKEN'));
expect(testMediumAccount).toBeInstanceOf(medium.MediumAccount);
2020-11-16 03:15:49 +00:00
});
tap.test('should get me info', async () => {
2020-11-16 23:04:54 +00:00
const result = await testMediumAccount.getAccountInfo();
console.log(result);
2020-11-16 23:04:54 +00:00
});
tap.test('should get publications', async () => {
const result = await testMediumAccount.getAllPublications();
2020-11-16 23:04:54 +00:00
// console.log(result);
});
tap.test('should get own publications', async () => {
const result = await testMediumAccount.getOwnPublications();
2020-11-16 03:15:49 +00:00
// console.log(result);
2020-11-16 01:37:00 +00:00
});
tap.test('should get a publication by name', async () => {
const result = await testMediumAccount.getPublicationByName('mojoio-test');
console.log(result);
});
tap.test('should create a post', async () => {
const mojoioTestPublication = await testMediumAccount.getPublicationByName('mojoio-test');
const newPost = await mojoioTestPublication.createPost({
title: 'a test title',
contentFormat: 'html',
canonicalUrl: 'https://mojo.io/testarticle',
content: '<h1>hello</1> So awesome',
publishStatus: 'draft',
tags: []
});
console.log(newPost);
})
2020-11-16 01:37:00 +00:00
tap.start();