Use new singleton instance of Client

This commit is contained in:
Tee
2021-03-04 00:08:46 -05:00
parent 4238438adb
commit f47353849a

View File

@ -1,86 +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'
}];
it('should get a single using the cards resource and query params' , () => {
const params: Query[] = [{
name: 'id',
value: 'xy7-54'
}];
Client.get('cards', params)
.then(response => {
expect(response).to.be.a('array');
expect(response[0].name).to.equal('Ampharos');
});
});
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('cards')
.then(response => {
expect(response).to.be.a('array');
expect(response.length).to.equal(250);
});
});
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'
}];
it('should get sets using the sets resource and query params', () => {
const params: Query[] = [{
name: 'name',
value: 'Base'
}];
Client.get('sets', params)
.then(response => {
expect(response).to.be.a('array');
expect(response[0]).to.be.a('object');
});
});
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'
}];
it('should get a single set using the sets resource and query params', () => {
const params: Query[] = [{
name: 'id',
value: 'base1'
}];
Client.get('sets', params)
.then(response => {
expect(response).to.be.a('array');
expect(response[0].name).to.equal('Base');
});
});
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('sets')
.then(response => {
expect(response).to.be.a('array');
expect(response[0]).to.be.a('object');
expect(response[0].id).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');
});
});
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');
});
});
});