Move test files to test directory
This commit is contained in:
66
test/client.test.ts
Normal file
66
test/client.test.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import * as chai from 'chai';
|
||||
import { Client } from '../src/client';
|
||||
import { Query } from '../src/interfaces/query';
|
||||
import { Card } from "../src/interfaces/card";
|
||||
import { Set } from "../src/interfaces/set";
|
||||
|
||||
const expect = chai.expect;
|
||||
const client: Client = Client.getInstance();
|
||||
|
||||
describe('Client', () => {
|
||||
it('should get a single using the cards resource and query params' , () => {
|
||||
const params: Query[] = [{
|
||||
name: 'id',
|
||||
value: 'xy7-54'
|
||||
}];
|
||||
|
||||
client.get<Card[]>('cards', params)
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0].name).to.equal('Ampharos');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a default list of cards using the cards resource with no query params', () => {
|
||||
client.get<Card[]>('cards')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response.length).to.equal(250);
|
||||
});
|
||||
});
|
||||
|
||||
it('should get sets using the sets resource and query params', () => {
|
||||
const params: Query[] = [{
|
||||
name: 'name',
|
||||
value: 'Base'
|
||||
}];
|
||||
|
||||
client.get<Set[]>('sets', params)
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0]).to.be.a('object');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a single set using the sets resource and query params', () => {
|
||||
const params: Query[] = [{
|
||||
name: 'id',
|
||||
value: 'base1'
|
||||
}];
|
||||
|
||||
client.get<Set[]>('sets', params)
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0].name).to.equal('Base');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a default list of sets using the sets resource with no query params', () => {
|
||||
client.get<Set[]>('sets')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0]).to.be.a('object');
|
||||
expect(response[0].id).to.equal('base1');
|
||||
});
|
||||
});
|
||||
});
|
||||
38
test/queryBuilder.test.ts
Normal file
38
test/queryBuilder.test.ts
Normal file
@ -0,0 +1,38 @@
|
||||
// import * as chai from 'chai';
|
||||
// import { Card } from '../src/classes/card';
|
||||
// import { QueryBuilder } from '../src/queryBuilder';
|
||||
// import { Query } from '../src/interfaces/query';
|
||||
//
|
||||
// const expect = chai.expect;
|
||||
// describe('QueryBuilder', () => {
|
||||
// it('should use find to get a single instance', () => {
|
||||
// QueryBuilder.find<Card>(Card, 'xy7-54')
|
||||
// .then(card => {
|
||||
// expect(card).to.be.a('object');
|
||||
// expect(card.name).to.equal('Gardevoir');
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should use where to filter data', () => {
|
||||
// const params: Query[] = [
|
||||
// {
|
||||
// name: 'q',
|
||||
// value: 'name:Charizard set.id:base1'
|
||||
// }
|
||||
// ];
|
||||
//
|
||||
// QueryBuilder.where<Card>(Card, params)
|
||||
// .then(cards => {
|
||||
// expect(cards.length).to.equal(1);
|
||||
// expect(cards[0].id).to.equal('base1-4');
|
||||
// expect(cards[0].set.name).to.equal('Base');
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should use all to get all cards', () => {
|
||||
// QueryBuilder.all<Card>(Card)
|
||||
// .then(cards => {
|
||||
// expect(cards.length).to.equal(250);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
Reference in New Issue
Block a user