Skip to content

Commit

Permalink
Merge pull request #49 from canjs/landscaper/qunit2
Browse files Browse the repository at this point in the history
Landscaper: QUnit2 upgrade
  • Loading branch information
cherifGsoul authored May 26, 2019
2 parents 1c0c7fd + d426809 commit 4bc76d1
Show file tree
Hide file tree
Showing 6 changed files with 9,065 additions and 35 deletions.
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

0 comments on commit 4bc76d1

Please sign in to comment.