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 #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"detect-cyclic-packages": "^1.1.0",
"jshint": "^2.7.0",
"steal": "^1.0.1",
"steal-qunit": "^1.0.0",
"steal-qunit": "^2.0.0",
"steal-tools": "^1.0.0",
"testee": "^0.9.0"
},
Expand Down
50 changes: 25 additions & 25 deletions src/get_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var items = [
{ id: 7, note: 'C', type: 'critical' }
];

test("getSubset against non ranged set", function(){
QUnit.test("getSubset against non ranged set", function(assert) {
/*
* 1. set b = {} evaluates to all available entities -- the univeral set
* 2. set a = { type: 'critical', start: 1, end: 3 } evaluates to entities
Expand All @@ -41,10 +41,10 @@ test("getSubset against non ranged set", function(){
var res = set.getSubset({ type: 'critical', start: 1, end: 3 }, {}, items,
props.rangeInclusive("start", "end"));

deepEqual(res && h.map.call(res, getId), [2,4,6]);
assert.deepEqual(res && h.map.call(res, getId), [2,4,6]);
});

test("getSubset ordered ascending and paginated", function() {
QUnit.test("getSubset ordered ascending and paginated", function(assert) {
/*
* 1. set b = {} evaluates to all available entities -- the univeral set
* 2. set a = { type: 'critical', sort: 'note ASC', start: 1, end: 3 }
Expand Down Expand Up @@ -74,10 +74,10 @@ test("getSubset ordered ascending and paginated", function() {
{}, items, algebra
);

deepEqual(res && h.map.call(res, getId), [7,1,2]);
assert.deepEqual(res && h.map.call(res, getId), [7,1,2]);
});

test("getSubset ordered descending and paginated", function() {
QUnit.test("getSubset ordered descending and paginated", function(assert) {
/*
* 1. set b = {} evaluates to all available entities -- the univeral set
* 2. set a = { type: 'critical', sort: 'note DESC', start: 1, end: 3 }
Expand All @@ -102,51 +102,51 @@ test("getSubset ordered descending and paginated", function() {
{}, items, algebra
);

deepEqual(res && h.map.call(res, getId), [2,1,7]);
assert.deepEqual(res && h.map.call(res, getId), [2,1,7]);
});

test("getSubset against paginated set", function(){
QUnit.test("getSubset against paginated set", function(assert) {
var res = set.getSubset(
{type: 'critical', start: 21, end: 23},
{type: 'critical', start: 20, end: 27},
items,
props.rangeInclusive("start","end") );

deepEqual(res && h.map.call(res, getId), [2,4,6]);
assert.deepEqual(res && h.map.call(res, getId), [2,4,6]);
});

test("getSubset returns undefined against incompatible set", function() {
QUnit.test("getSubset returns undefined against incompatible set", function(assert) {
var res = set.getSubset(
{ note: 'C' },
{ type: 'critical' },
items
);

strictEqual(res, undefined);
assert.strictEqual(res, undefined);
});

test("getUnion basics", function(){
QUnit.test("getUnion basics", function(assert) {
var union = set.getUnion({}, { foo: "bar" }, items, items.slice(0, 3));
deepEqual(union, items);
assert.deepEqual(union, items);
});

test("getUnion against ranged sets", function(){
QUnit.test("getUnion against ranged sets", function(assert) {
var union = set.getUnion({start: 10, end: 13},{start: 14, end: 17},items.slice(0,4), items.slice(4,8), props.rangeInclusive("start","end"));
deepEqual(union, items);
assert.deepEqual(union, items);

union = set.getUnion({start: 14, end: 17}, {start: 10, end: 13}, items.slice(4,8),items.slice(0,4), props.rangeInclusive("start","end"));
deepEqual(union, items, "disjoint after");
assert.deepEqual(union, items, "disjoint after");
});

test("getUnion against overlapping ranged sets", function(){
QUnit.test("getUnion against overlapping ranged sets", function(assert) {
var union = set.getUnion(
{start: 10, end: 14},
{start: 13, end: 17},
items.slice(0,5),
items.slice(3,8),
props.rangeInclusive("start","end"));

deepEqual(union, items);
assert.deepEqual(union, items);

union = set.getUnion(
{start: 10, end: 11},
Expand All @@ -155,7 +155,7 @@ test("getUnion against overlapping ranged sets", function(){
items.slice(1,8),
props.rangeInclusive("start","end"));

deepEqual(union, items);
assert.deepEqual(union, items);

union = set.getUnion(
{start: 11, end: 17},
Expand All @@ -164,10 +164,10 @@ test("getUnion against overlapping ranged sets", function(){
items.slice(0,2),
props.rangeInclusive("start","end"));

deepEqual(union, items);
assert.deepEqual(union, items);
});

test("getUnion filters for uniqueness", function(){
QUnit.test("getUnion filters for uniqueness", function(assert) {
var aItems = items.filter(function(a) {
return a.type === "critical";
});
Expand All @@ -177,24 +177,24 @@ test("getUnion filters for uniqueness", function(){
var unionItems = aItems.concat([bItems[0]]); // bItems[1] is already in aItems

var union = set.getUnion({type: "critical"},{note: "C"}, aItems, bItems, props.id("id"));
deepEqual(union, unionItems);
assert.deepEqual(union, unionItems);

// case with no ID in set algebra, but some same items.
union = set.getUnion({type: "critical"},{note: "C"}, aItems, bItems, {});
deepEqual(union, unionItems);
assert.deepEqual(union, unionItems);

// Case with not-same items with same ID
bItems = bItems.map(function(b) {
return assign({}, b);
});
union = set.getUnion({type: "critical"},{note: "C"}, aItems, bItems, props.id("id"));
deepEqual(union, unionItems);
assert.deepEqual(union, unionItems);

});

test("getSubset passed same object works (#3)", function(){
QUnit.test("getSubset passed same object works (#3)", function(assert) {
var algebra = new set.Algebra(props.rangeInclusive("start","end"));
var setObj = {start: 1, end: 2};
var items = algebra.getSubset(setObj, setObj, [{id: 1}]);
deepEqual(items, [{id: 1}]);
assert.deepEqual(items, [{id: 1}]);
});
28 changes: 14 additions & 14 deletions src/prop_tests/boolean_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ QUnit.module("can-set props.boolean");
*
*
*/
test('boolean set.difference', function() {
QUnit.test('boolean set.difference', function(assert) {

var prop = props.boolean('completed');

Expand All @@ -25,7 +25,7 @@ test('boolean set.difference', function() {
* z ∈ (X / Y) | y.completed = false
*/
var res = set.difference({} , { completed: true }, prop);
deepEqual(res, {completed: false}, "inverse of true");
assert.deepEqual(res, {completed: false}, "inverse of true");

/*
* x ∈ {} | x.completed = true OR x.completed = false
Expand All @@ -34,7 +34,7 @@ test('boolean set.difference', function() {
* z ∈ (X / Y) | y.completed = false
*/
res = set.difference({}, { completed: false }, prop);
deepEqual(res, {completed: true} , "inverse of false");
assert.deepEqual(res, {completed: true} , "inverse of false");
});

/*
Expand All @@ -44,10 +44,10 @@ test('boolean set.difference', function() {
*
* (X U Y) = c
*/
test('boolean set.union', function(){
QUnit.test('boolean set.union', function(assert) {
var prop = props.boolean('completed');
var res = set.union({completed: false} , { completed: true }, prop);
deepEqual(res, {}, "union of true and false is entire boolean set");
assert.deepEqual(res, {}, "union of true and false is entire boolean set");
});

/*
Expand All @@ -69,29 +69,29 @@ test('boolean set.union', function(){
*
* Only requires that one property is always on an element
*/
test('boolean set.intersection', function(){
QUnit.test('boolean set.intersection', function(assert) {
var prop = props.boolean('completed');
var res = set.intersection({foo: "bar"} , { completed: true }, prop);
deepEqual(res, {foo: "bar", completed: true}, "intersection is false (#4)");
assert.deepEqual(res, {foo: "bar", completed: true}, "intersection is false (#4)");
});


test('strings false and true are treated as booleans', function(){
QUnit.test('strings false and true are treated as booleans', function(assert) {
var prop = props.boolean('completed');
var res = set.subset({} , { completed: "true" }, prop);
ok(!res, "{} and 'true' not a subset");
assert.ok(!res, "{} and 'true' not a subset");
res = set.subset({} , { completed: "false" }, prop);
ok(!res, "{} and 'false' not a subset");
assert.ok(!res, "{} and 'false' not a subset");

res = set.subset({ completed: "true" }, {}, prop);
ok(res, "subset");
assert.ok(res, "subset");

res = set.subset({ completed: "false" }, {}, prop);
ok(res, "subset");
assert.ok(res, "subset");

res = set.union({completed: 'false'} , { completed: 'true' }, prop);
deepEqual(res, {}, "union of true and false is entire boolean set");
assert.deepEqual(res, {}, "union of true and false is entire boolean set");

res = set.equal({completed: false} , { completed: "false" }, prop);
ok(res, "false and 'false'");
assert.ok(res, "false and 'false'");
});
28 changes: 14 additions & 14 deletions src/prop_tests/dotNotation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ QUnit.module("can-set props.dotNotation");
* x ∈ X | x.n.p = 'IL'
*
*/
test('dotNotation set membership', function() {
QUnit.test('dotNotation set membership', function(assert) {
/*
* For a property 'n.p', with value 'IL'
* x ∈ X | x.n.p == 'IL'
*/
var prop = props.dotNotation('n.p'),
alg = new set.Algebra(prop),
res = alg.has({'n.p': 'IL'}, {n:{p:'IL'}});
ok(res, "object with nested property is member of set using dotNotation");
assert.ok(res, "object with nested property is member of set using dotNotation");

/*
* For a property 'n.p', with value 'IL'
* x ∉ X | x.n.p != 'IL'
*/
res = alg.has({'n.p': 'IL'}, {n:{p:'MI'}});
ok(res === false, "object with nested property not a member of set using dotNotation");
assert.ok(res === false, "object with nested property not a member of set using dotNotation");

/*
* For a property 'n.p.s', with value 'IL'
Expand All @@ -36,10 +36,10 @@ test('dotNotation set membership', function() {
prop = props.dotNotation('n.p.s');
alg = new set.Algebra(prop);
res = alg.has({'n.p.s': 'IL'}, {n:{p:{s:'IL'}}});
ok(res, "object with deep nested property is member of set using dotNotation");
assert.ok(res, "object with deep nested property is member of set using dotNotation");
});

test('dotNotation set equality', function() {
QUnit.test('dotNotation set equality', function(assert) {
var prop = props.dotNotation('n.p'),
alg = new set.Algebra(prop),
set1 = {'n.p': 'IL'},
Expand All @@ -50,20 +50,20 @@ test('dotNotation set equality', function() {
/*
* {x | x ∈ X, x.n.p == 'IL'} = {y | y ∈ Y, y.n.p == 'IL'}
*/
ok(alg.equal(set1, set2) && alg.equal(set2, set1), "sets with dotNotation properties are equivalent");
assert.ok(alg.equal(set1, set2) && alg.equal(set2, set1), "sets with dotNotation properties are equivalent");

/*
* {x | x ∈ X, x.n.p == 'IL'} != {y | y ∈ Y, y.n.p == 'MI'}
*/
ok(alg.equal(set1, set3) === false, "sets with dotNotation properties are not equivalent");
assert.ok(alg.equal(set1, set3) === false, "sets with dotNotation properties are not equivalent");

/*
* {x | x ∈ X, x.n.p == 'MI'} = {y | y ∈ Y, y.n.p == 'MI'}
*/
ok(alg.equal(set4, set3) === false, "sets with dotNotation properties are equivalent to sets with nested properties");
assert.ok(alg.equal(set4, set3) === false, "sets with dotNotation properties are equivalent to sets with nested properties");
});

test('dotNotation set subset', function() {
QUnit.test('dotNotation set subset', function(assert) {
var alg = new set.Algebra(
props.dotNotation('address.state'),
props.dotNotation('address.city')
Expand All @@ -75,20 +75,20 @@ test('dotNotation set subset', function() {
/*
* {x | x ∈ X, x.address.state = 'IL', x.address.city = 'Chicago'} ⊆ {y | y ∈ Y, y.address.state == 'IL'}
*/
ok(alg.subset(set2, set1), "sets with dotNotation property is a subset of another dotNotation set");
assert.ok(alg.subset(set2, set1), "sets with dotNotation property is a subset of another dotNotation set");

/*
* {x | x ∈ X, x.address.state = 'IL', x.address.city = 'Chicago'} ⊆ {y | y ∈ Y, y.address.state == 'IL'}
*/
ok(alg.subset(set3, set1), "sets with nested property notation is a subset of a dotNotation set");
assert.ok(alg.subset(set3, set1), "sets with nested property notation is a subset of a dotNotation set");

/*
* {y | y ∈ Y, y.address.state == 'IL'} ⊆ ξ
*/
ok(alg.subset(set1, {}), "sets with dotNotation properties are subsets of the universal set");
assert.ok(alg.subset(set1, {}), "sets with dotNotation properties are subsets of the universal set");

/*
* ξ ⊄ {y | y ∈ Y, y.address.state == 'IL'}
*/
ok(alg.subset({}, set1) === false, "the universal set is not a subset of a set with dotNotation");
});
assert.ok(alg.subset({}, set1) === false, "the universal set is not a subset of a set with dotNotation");
});
Loading