Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// First Valid Item Request
.get(path)
.query({
appid: Application.CSGO,
currency: Currency.GBP,
market_hash_name: 'FirstItem',
})
.reply(200, {
lowest_price: '£1.00',
median_price: '£1.30',
success: true,
volume: '328',
});
const API = new Market({ id: Application.CSGO, currency: Currency.GBP });
test('One Item', async (t) => {
const item = await API.getPrice('FirstItem');
const should = {
id: 'FirstItem',
price: {
code: 'GBP',
lowest: 1,
median: 1.3,
sign: '£',
type: 'pound',
},
volume: 328,
};
t.deepEqual(item, should);
});
.query({
appid: Application.CSGO,
currency: Currency.USD,
market_hash_name: 'DoesNotExist500',
})
.reply(500, {success: false})
// Non-Existent Item With Status Code 404
.get(path)
.query({
appid: Application.CSGO,
currency: Currency.USD,
market_hash_name: 'DoesNotExist404',
})
.reply(404, {success: false});
const API = new Market({ id: Application.CSGO, currency: Currency.USD });
test(`One Item That Doesn't Exist | 500`, async (t) => {
const item = await t.throwsAsync(API.getPrice('DoesNotExist500'));
t.deepEqual(item.message, 'Item Not Found! Status: 500');
});
test(`One Item That Doesn't Exist | 404`, async (t) => {
const item = await t.throwsAsync(API.getPrice('DoesNotExist404'));
t.deepEqual(item.message, 'Item Not Found! Status: 404');
});
// First Valid Item Request
nock(base)
.get(path)
.query({
appid: Application.CSGO,
currency: Currency.USD,
market_hash_name: 'FirstItem',
})
.reply(200, {
lowest_price: '$1.00',
median_price: '$1.30',
success: true,
volume: '328',
});
const API = new Market({ id: Application.CSGO, currency: Currency.EUR });
test('One Item', async (t) => {
const item = await API.getPrice('FirstItem', { currency: Currency.USD });
const should = {
id: 'FirstItem',
price: {
code: 'USD',
lowest: 1,
median: 1.3,
sign: '$',
type: 'us-dollar',
},
volume: 328,
};
t.deepEqual(item, should);
});
import {
base,
path,
} from 'test/settings';
// One Item Rate Limited Request
nock(base)
.get(path)
.query({
appid: Application.CSGO,
currency: Currency.USD,
market_hash_name: 'TestRateLimitForOneItem',
})
.reply(429);
const API = new Market({ id: Application.CSGO, currency: Currency.USD });
test('Steam API Rate Limiting For One Item', async (t) => {
const error = await t.throwsAsync(API.getPrice('TestRateLimitForOneItem'));
t.is(error.message, 'Steam API Rate Limit Exceeded!');
});
path,
} from 'test/settings';
// First Valid Item Request
nock(base)
.get(path)
.query({
appid: Application.CSGO,
currency: Currency.USD,
market_hash_name: 'FirstEmptyItem',
})
.reply(200, {
success: true,
});
const API = new Market({ id: Application.CSGO, currency: Currency.USD });
test('One Empty Item', async (t) => {
const exception: error.Exception = await t.throwsAsync(API.getPrice('FirstEmptyItem')) as any;
t.is(exception.code, error.codes.ITEM_NO_DATA);
t.is(exception.message, error.messages.ITEM_NO_DATA);
});