Moved tests and updated Set
This commit is contained in:
@ -14,6 +14,7 @@ export class Set implements ISet {
|
||||
symbolUrl: string;
|
||||
totalCards: number;
|
||||
updatedAt: string;
|
||||
updatedSince: string;
|
||||
|
||||
resource(): string {
|
||||
return 'sets';
|
||||
|
||||
@ -1,86 +0,0 @@
|
||||
import * as chai from 'chai';
|
||||
import { Client } from '../client';
|
||||
import { IQuery } from '../interfaces/query';
|
||||
|
||||
const expect = chai.expect;
|
||||
describe('Client', () => {
|
||||
it('should get a single using the cards resource and query params' , () => {
|
||||
const params: IQuery[] = [{
|
||||
name: 'id',
|
||||
value: 'xy7-54'
|
||||
}];
|
||||
|
||||
Client.get('cards', params)
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0].name).to.equal('Gardevoir');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a default list of cards using the cards resource with no query params', () => {
|
||||
Client.get('cards')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response.length).to.equal(100);
|
||||
});
|
||||
});
|
||||
|
||||
it('should get sets using the sets resource and query params', () => {
|
||||
const params: IQuery[] = [{
|
||||
name: 'name',
|
||||
value: 'Base'
|
||||
}];
|
||||
|
||||
Client.get('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: IQuery[] = [{
|
||||
name: 'id',
|
||||
value: 'base1'
|
||||
}];
|
||||
|
||||
Client.get('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('sets')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0]).to.be.a('object');
|
||||
expect(response[0].code).to.equal('base1');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a list of types using the types resource', () => {
|
||||
Client.get('types')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0]).to.be.a('string');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a list of supertypes using the supertypes resource', () => {
|
||||
Client.get('supertypes')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0]).to.be.a('string');
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a list of subtypes using the subtypes resource', () => {
|
||||
Client.get('subtypes')
|
||||
.then(response => {
|
||||
expect(response).to.be.a('array');
|
||||
expect(response[0]).to.be.a('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,43 +0,0 @@
|
||||
import * as chai from 'chai';
|
||||
import { Card } from '../classes/card';
|
||||
import { QueryBuilder } from '../queryBuilder';
|
||||
import { IQuery } from '../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: IQuery[] = [
|
||||
{
|
||||
name: 'name',
|
||||
value: 'Charizard'
|
||||
|
||||
},
|
||||
{
|
||||
name: 'setCode',
|
||||
value: '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).to.equal('Base');
|
||||
});
|
||||
});
|
||||
|
||||
it('should use all to get all cards', () => {
|
||||
QueryBuilder.all<Card>(Card)
|
||||
.then(cards => {
|
||||
expect(cards.length).to.equal(1000);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user