Skip to content

Commit

Permalink
Remove invalid and unnecessary tests
Browse files Browse the repository at this point in the history
They're still failing, however, due to an ava deficiency.
See avajs/ava#2293.
  • Loading branch information
shreyasminocha committed Dec 19, 2019
1 parent e2657b7 commit 5f7704f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"utf-8": "^2.0.0"
},
"devDependencies": {
"ava": "^0.25.0"
"ava": "^1.0.0"
},
"repository": {
"type": "git",
Expand Down
60 changes: 17 additions & 43 deletions test/tests.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,62 @@
'use strict';

import test from 'ava';
import app from '../app.js';

test('Loads credentials', t => {
const credentials = app.credentials;
const properties = [
'CLIENT_ID',
'CLIENT_SECRET',
'REDDIT_USER',
'REDDIT_PASS'
];

for (let propertyName of properties) {
t.truthy(credentials[propertyName]);
t.is(typeof credentials[propertyName], 'string');
}
});

test('Creates a Snoostrom client', t => {
t.true(app.client instanceof require('snoostorm'));
});

test('Creates a valid comment stream', t => {
t.true(app.comments instanceof require('events'));
t.true('comment' in app.comments._events);
});
import decode from '../util/decode';

test('Decodes delimited strings', t => {
t.is(app.decode('01110000 01100001 01110011 01110011'), 'pass');
t.is(decode('01110000 01100001 01110011 01110011'), 'pass');
});

test('Decodes non-delimited strings', t => {
t.is(app.decode('01110000011000010111001101110011'), 'pass');
t.is(decode('01110000011000010111001101110011'), 'pass');
});

test('Decodes strings with whitespace padding', t => {
t.is(app.decode('\t01110000 01100001 01110011 01110011 \n'), 'pass');
t.is(decode('\t01110000 01100001 01110011 01110011 \n'), 'pass');
});

test('Decodes binary on separate line', t => {
t.is(app.decode('text \n01110000 01100001 01110011 01110011'), 'pass');
t.is(decode('text \n01110000 01100001 01110011 01110011'), 'pass');
});

test('Decodes UTF-8', t => {
t.is(app.decode('00100100 11000010 10100010 11100010 10000010 10101100 11110000 10010000 10001101 10001000'), '$¢€𐍈');
t.is(decode('00100100 11000010 10100010 11100010 10000010 10101100 11110000 10010000 10001101 10001000'), '$¢€𐍈');
});

test('Fails on incomplete bytes (delimited)', t => {
t.is(app.decode('01110000 01100001 01110011 0111001'), '');
t.is(app.decode('01110000 0100001 01110011 01110011'), '');
t.is(decode('01110000 01100001 01110011 0111001'), '');
t.is(decode('01110000 0100001 01110011 01110011'), '');
});

test('Fails on incomplete bytes (non-delimited)', t => {
t.is(app.decode('011100000110000101110011011100101'), '');
t.is(decode('011100000110000101110011011100101'), '');
});

test('Fails on invalid UTF', t => {
t.is(app.decode('100000000000000000000000'), '');
t.is(decode('100000000000000000000000'), '');
});

test('Fails on text followed by binary', t => {
t.is(app.decode('text text text 01110000 01100001 01110011'), '');
t.is(decode('text text text 01110000 01100001 01110011'), '');
});

test('Fails on less than three bytes', t => {
t.is(app.decode('01101000 01101001'), '');
t.is(app.decode('01101001'), '');
t.is(decode('01101000 01101001'), '');
t.is(decode('01101001'), '');

t.not(app.decode('01101000 01101001 01101001'), '');
t.not(decode('01101000 01101001 01101001'), '');
});

test('Fails on non-binary', t => {
t.is(app.decode('clearly not binary'), '');
t.is(decode('clearly not binary'), '');
});

test('Fails on empty string', t => {
t.is(app.decode(''), '');
t.is(decode(''), '');
});

test('Throws `TypeError` on non-string parameters', t => {
const nonStringTypes = [null, undefined, NaN, true, false, 10101010, [], {}];

for (let type of nonStringTypes) {
t.throws(() => app.decode(type), TypeError);
t.throws(() => decode(type), TypeError);
}
});

0 comments on commit 5f7704f

Please sign in to comment.