Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landscaper: QUnit2 upgrade #49

Merged
merged 10 commits into from
May 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
sudo: required
dist: trusty
language: node_js
node_js: node
node_js:
- "10"
addons:
chrome: stable
sauce_connect: true
apt:
packages:
- xvfb
before_script:
- 'export DISPLAY=:99.0'
- sh -e /etc/init.d/xvfb start &
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm run http-server &
- sleep 3
- "sudo chown root /opt/google/chrome/chrome-sandbox"
Expand Down
32 changes: 16 additions & 16 deletions can-ndjson-stream-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ try {
}

var conditionalTest = isReadStreamSupported ? QUnit.test : QUnit.skip;
var conditionalAsyncTest = isReadStreamSupported ? QUnit.asyncTest : QUnit.skip;
var conditionalAsyncTest = isReadStreamSupported ? QUnit.test : QUnit.skip;

function readableStreamFromString(s) {
return new ReadableStream({
Expand Down Expand Up @@ -57,33 +57,33 @@ function inputStream(objArray) {

QUnit.module('can-ndjson-stream');

conditionalTest('Initialized the plugin', function(){
QUnit.equal(typeof ndjsonStream, 'function');
conditionalTest('Initialized the plugin', function(assert){
assert.equal(typeof ndjsonStream, 'function');
});

conditionalAsyncTest('simple_test_from_stream', function(assert) {

var testObject = [
{"date":"2017-02-24 03:07:45","user":"21109850","fuel":"37","ammo":"2","steel":"13","baux":"5","seaweed":"0","type":"LOOT","product":"134"},
{"date":"2017-02-22 04:40:13","user":"21109850","fuel":"37","ammo":"2","steel":"13","baux":"5","seaweed":"0","type":"LOOT","product":"75"},
{"date":"2017-02-21 20:47:51","user":"26464462","fuel":"37","ammo":"3","steel":"19","baux":"5","seaweed":"1","type":"LOOT","product":"81"}
];
var readObjects = [];

var todoStream = ndjsonStream( inputStream(testObject) );
var reader = todoStream.getReader();

var done = assert.async();

function test(todosStream) {
var reader = todosStream.getReader();
reader.read().then(function read(result) {
if (result.done) {
assert.deepEqual(readObjects, testObject, "Two arrays should be the same in value");
QUnit.start();
done();
return;
}
readObjects.push(result.value);
reader.read().then(read);

return reader.read().then(read);
});
}
test(todoStream);
});

conditionalAsyncTest('malformed json', function(assert) {
Expand All @@ -95,9 +95,9 @@ conditionalAsyncTest('malformed json', function(assert) {
function errCheck() {
errorCaught = true;
}

var done = assert.async();
var allDone = reader.read().then(function read(result) {
if (result.done) {
if (result.start) {
return;
}
readObjects.push(result.value);
Expand All @@ -106,11 +106,11 @@ conditionalAsyncTest('malformed json', function(assert) {

allDone.then(function(){
assert.strictEqual(errorCaught, true, "malformed json string should cause an error");
QUnit.start();
}, function(){
done();
}, function(){

assert.strictEqual(errorCaught, true, "rejected: malformed json string should cause an error");
QUnit.start();
done();
});

});

2 changes: 1 addition & 1 deletion can-ndjson-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ var ndjsonStream = function(response) {
});
};

module.exports = namespace.ndjsonStream = ndjsonStream;
module.exports = namespace.ndjsonStream = ndjsonStream;
Loading