Skip to content

Commit

Permalink
add test cases for create board and remove board
Browse files Browse the repository at this point in the history
  • Loading branch information
BL committed Dec 29, 2018
1 parent 6cc79b7 commit 1929c51
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/intialize/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CONFIG = {
TRELLO_API_KEY: process.env.TRELLO_API_KEY || 'YOUR_API_KEY',
TRELLO_OAUTH_TOKEN: process.env.TRELLO_OAUTH_TOKEN || 'OAUTH_TOKEN'
TRELLO_API_KEY: process.env.TRELLO_API_KEY || undefined,
TRELLO_OAUTH_TOKEN: process.env.TRELLO_OAUTH_TOKEN || undefined
};
45 changes: 36 additions & 9 deletions test/resources/Board.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import {CONFIG} from '../intialize';
import * as TrelloNodeAPI from 'trello-node-api';
import * as TrelloNodeAPI from '../../lib/trello-node-api';

import * as chai from 'chai';

const expect = chai.expect;

const apiKey = CONFIG.TRELLO_API_KEY;
const oauthToken = CONFIG.TRELLO_OAUTH_TOKEN;

const Trello = new TrelloNodeAPI();
Trello.setApiKey(apiKey);
Trello.setOauthToken(oauthToken);
/* tslint:disable:no-string-literal */
describe('Board', () => {

it('It should create the Board', async () => {
let boardDocument: any = {};
describe('Board', function () {

before(function () {
expect(apiKey).to.be.a('string');
expect(oauthToken).to.be.a('string');
});

it('It should create the Board', async function () {
const boardName = 'Auto generated board ' + new Date().getUTCMilliseconds();
let data = {
name: 'BOARD_NAME_1', // REQUIRED
name: boardName, // REQUIRED
defaultLabels: false,
defaultLists: false,
desc: 'Board description.',
idOrganization: 'ORGANIZATION_ID',
desc: 'This is test board. Here is the Board description.',
keepFromSource: 'none',
powerUps: 'all',
prefs_permissionLevel: 'private',
Expand All @@ -28,8 +38,25 @@ describe('Board', () => {
prefs_background: 'blue',
prefs_cardAging: 'regular'
};
let response = await Trello.board.create(data);
console.log('response', response);
try {
let response = await Trello.board.create(data);
console.log('response', response);
boardDocument = response;
expect(response).to.be.a('object');
} catch (error) {
console.log('error ', error);
expect(error).to.be.undefined;
}
});

it('It should delete the Board', async function () {
try {
let response = await Trello.board.del(boardDocument.id);
console.log('response', response);
expect(response).to.be.a('object');
} catch (error) {
console.log('error ', error);
expect(error).to.be.undefined;
}
});
});

0 comments on commit 1929c51

Please sign in to comment.