Skip to content

Commit c7905e5

Browse files
WIP: added integration test cases
1 parent 9598402 commit c7905e5

File tree

1 file changed

+299
-1
lines changed

1 file changed

+299
-1
lines changed

test/entry/find.js

Lines changed: 299 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,4 +1360,302 @@ test('.except() - For the reference - Array', function(assert) {
13601360
assert.fail(".except() - For the reference - Array");
13611361
assert.end();
13621362
});
1363-
});
1363+
});
1364+
1365+
// Taxonomies Endpoint
1366+
test('Taxonomies Endpoint: Get Entries With One Term', function(assert) {
1367+
let Query = Stack.Taxonomies().Query();
1368+
Query
1369+
.where('taxonomies.one', 'term_one')
1370+
.toJSON()
1371+
.find()
1372+
.then(entries => {
1373+
assert.ok(entries[0].length, 'Entries present in the resultset');
1374+
assert.end();
1375+
}, err => {
1376+
console.error("error :", err);
1377+
assert.fail("Taxonomies Endpoint: Get Entries With One Term");
1378+
assert.end();
1379+
})
1380+
});
1381+
1382+
test('Taxonomies Endpoint: Get Entries With Any Term ($in)', function(assert) {
1383+
let Query = Stack.Taxonomies().Query();
1384+
Query
1385+
.containedIn('taxonomies.one', ['term_one', 'term_two'])
1386+
.toJSON()
1387+
.find()
1388+
.then(entries => {
1389+
assert.ok(entries[0].length, 'Entries present in the resultset');
1390+
assert.end();
1391+
}, err => {
1392+
console.error("error :", err);
1393+
assert.fail("Taxonomies Endpoint: Get Entries With Any Term ($in)");
1394+
assert.end();
1395+
})
1396+
})
1397+
1398+
test('Taxonomies Endpoint: Get Entries With Any Term ($or)', function(assert) {
1399+
let Query = Stack.Taxonomies().Query();
1400+
let Query1 = Stack.Taxonomies().Query().where('taxonomies.one', 'term_one');
1401+
let Query2 = Stack.Taxonomies().Query().where('taxonomies.two', 'term_two');
1402+
Query
1403+
.or(Query1, Query2)
1404+
.toJSON()
1405+
.find()
1406+
.then(entries => {
1407+
assert.ok(entries[0].length, 'Entries present in the resultset');
1408+
assert.end();
1409+
}, err => {
1410+
console.error("error :", err);
1411+
assert.fail("Taxonomies Endpoint: Get Entries With Any Term ($or)");
1412+
assert.end();
1413+
})
1414+
})
1415+
1416+
test('Taxonomies Endpoint: Get Entries With All Terms ($and)', function(assert) {
1417+
let Query1 = Stack.Taxonomies().Query().where('taxonomies.one', 'term_one');
1418+
let Query2 = Stack.Taxonomies().Query().where('taxonomies.two', 'term_two');
1419+
let Query = Stack.Taxonomies().Query();
1420+
Query
1421+
.and(Query1, Query2)
1422+
.toJSON()
1423+
.find()
1424+
.then(entries => {
1425+
assert.ok(entries[0].length, 'Entries present in the resultset');
1426+
assert.end();
1427+
}, err => {
1428+
console.error("error :", err);
1429+
assert.fail("Taxonomies Endpoint: Get Entries With All Terms ($and)");
1430+
assert.end();
1431+
})
1432+
})
1433+
1434+
test('Taxonomies Endpoint: Get Entries With Any Taxonomy Terms ($exists)', function(assert) {
1435+
let Query = Stack.Taxonomies().Query();
1436+
Query
1437+
.exists('taxonomies.one')
1438+
.toJSON()
1439+
.find()
1440+
.then(entries => {
1441+
assert.ok(entries[0].length, 'Entries present in the resultset');
1442+
assert.end();
1443+
}, err => {
1444+
console.error("error :", err);
1445+
assert.fail("Taxonomies Endpoint: Get Entries With Any Taxonomy Terms ($exists)");
1446+
assert.end();
1447+
})
1448+
})
1449+
1450+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level)', function(assert) {
1451+
let Query = Stack.Taxonomies().Query();
1452+
Query
1453+
.equalAndBelow('taxonomies.one', 'term_one')
1454+
.toJSON()
1455+
.find()
1456+
.then(entries => {
1457+
assert.ok(entries[0].length, 'Entries present in the resultset');
1458+
assert.end();
1459+
}, err => {
1460+
console.error("error :", err);
1461+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level)");
1462+
assert.end();
1463+
})
1464+
})
1465+
1466+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level)', function(assert) {
1467+
let Query = Stack.Taxonomies().Query();
1468+
Query
1469+
.below('taxonomies.one', 'term_one')
1470+
.toJSON()
1471+
.find()
1472+
.then(entries => {
1473+
assert.ok(entries[0].length, 'Entries present in the resultset');
1474+
assert.end();
1475+
}, err => {
1476+
console.error("error :", err);
1477+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level)");
1478+
assert.end();
1479+
})
1480+
})
1481+
1482+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)', function(assert) {
1483+
let Query = Stack.Taxonomies().Query();
1484+
Query
1485+
.equalAndAbove('taxonomies.one', 'term_one')
1486+
.toJSON()
1487+
.find()
1488+
.then(entries => {
1489+
assert.ok(entries[0].length, 'Entries present in the resultset');
1490+
assert.end();
1491+
}, err => {
1492+
console.error("error :", err);
1493+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)");
1494+
assert.end();
1495+
})
1496+
})
1497+
1498+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)', function(assert) {
1499+
let Query = Stack.Taxonomies().Query();
1500+
Query
1501+
.above('taxonomies.one', 'term_one')
1502+
.toJSON()
1503+
.find()
1504+
.then(entries => {
1505+
assert.ok(entries[0].length, 'Entries present in the resultset');
1506+
assert.end();
1507+
}, err => {
1508+
console.error("error :", err);
1509+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)");
1510+
assert.end();
1511+
})
1512+
})
1513+
1514+
//Content Type end point
1515+
test('Taxonomies Endpoint: Get Entries With One Term', function(assert) {
1516+
let Query = Stack.ContentType('blog_post').Query();
1517+
Query
1518+
.where('taxonomies.one', 'term_one')
1519+
.toJSON()
1520+
.find()
1521+
.then(entries => {
1522+
assert.ok(entries[0].length, 'Entries present in the resultset');
1523+
assert.end();
1524+
}, err => {
1525+
console.error("error :", err);
1526+
assert.fail("Taxonomies Endpoint: Get Entries With One Term");
1527+
assert.end();
1528+
})
1529+
});
1530+
1531+
test('Taxonomies Endpoint: Get Entries With Any Term ($in)', function(assert) {
1532+
let Query = Stack.ContentType('blog_post').Query();
1533+
Query
1534+
.containedIn('taxonomies.one', ['term_one', 'term_two'])
1535+
.toJSON()
1536+
.find()
1537+
.then(entries => {
1538+
assert.ok(entries[0].length, 'Entries present in the resultset');
1539+
assert.end();
1540+
}, err => {
1541+
console.error("error :", err);
1542+
assert.fail("Taxonomies Endpoint: Get Entries With Any Term ($in)");
1543+
assert.end();
1544+
})
1545+
})
1546+
1547+
test('Taxonomies Endpoint: Get Entries With Any Term ($or)', function(assert) {
1548+
let Query = Stack.ContentType('blog_post').Query();
1549+
let Query1 = Stack.ContentType('blog_post').Query().where('taxonomies.one', 'term_one');
1550+
let Query2 = Stack.ContentType('blog_post').Query().where('taxonomies.two', 'term_two');
1551+
Query
1552+
.or(Query1, Query2)
1553+
.toJSON()
1554+
.find()
1555+
.then(entries => {
1556+
assert.ok(entries[0].length, 'Entries present in the resultset');
1557+
assert.end();
1558+
}, err => {
1559+
console.error("error :", err);
1560+
assert.fail("Taxonomies Endpoint: Get Entries With Any Term ($or)");
1561+
assert.end();
1562+
})
1563+
})
1564+
1565+
test('Taxonomies Endpoint: Get Entries With All Terms ($and)', function(assert) {
1566+
let Query1 = Stack.ContentType('blog_post').Query().where('taxonomies.one', 'term_one');
1567+
let Query2 = Stack.ContentType('blog_post').Query().where('taxonomies.two', 'term_two');
1568+
let Query = Stack.ContentType('blog_post').Query();
1569+
Query
1570+
.and(Query1, Query2)
1571+
.toJSON()
1572+
.find()
1573+
.then(entries => {
1574+
assert.ok(entries[0].length, 'Entries present in the resultset');
1575+
assert.end();
1576+
}, err => {
1577+
console.error("error :", err);
1578+
assert.fail("Taxonomies Endpoint: Get Entries With All Terms ($and)");
1579+
assert.end();
1580+
})
1581+
})
1582+
1583+
test('Taxonomies Endpoint: Get Entries With Any Taxonomy Terms ($exists)', function(assert) {
1584+
let Query = Stack.ContentType('blog_post').Query();
1585+
Query
1586+
.exists('taxonomies.one')
1587+
.toJSON()
1588+
.find()
1589+
.then(entries => {
1590+
assert.ok(entries[0].length, 'Entries present in the resultset');
1591+
assert.end();
1592+
}, err => {
1593+
console.error("error :", err);
1594+
assert.fail("Taxonomies Endpoint: Get Entries With Any Taxonomy Terms ($exists)");
1595+
assert.end();
1596+
})
1597+
})
1598+
1599+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level)', function(assert) {
1600+
let Query = Stack.ContentType('blog_post').Query();
1601+
Query
1602+
.equalAndBelow('taxonomies.one', 'term_one')
1603+
.toJSON()
1604+
.find()
1605+
.then(entries => {
1606+
assert.ok(entries[0].length, 'Entries present in the resultset');
1607+
assert.end();
1608+
}, err => {
1609+
console.error("error :", err);
1610+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level)");
1611+
assert.end();
1612+
})
1613+
})
1614+
1615+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level)', function(assert) {
1616+
let Query = Stack.ContentType('blog_post').Query();
1617+
Query
1618+
.below('taxonomies.one', 'term_one')
1619+
.toJSON()
1620+
.find()
1621+
.then(entries => {
1622+
assert.ok(entries[0].length, 'Entries present in the resultset');
1623+
assert.end();
1624+
}, err => {
1625+
console.error("error :", err);
1626+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level)");
1627+
assert.end();
1628+
})
1629+
})
1630+
1631+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)', function(assert) {
1632+
let Query = Stack.ContentType('blog_post').Query();
1633+
Query
1634+
.equalAndAbove('taxonomies.one', 'term_one')
1635+
.toJSON()
1636+
.find()
1637+
.then(entries => {
1638+
assert.ok(entries[0].length, 'Entries present in the resultset');
1639+
assert.end();
1640+
}, err => {
1641+
console.error("error :", err);
1642+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)");
1643+
assert.end();
1644+
})
1645+
})
1646+
1647+
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)', function(assert) {
1648+
let Query = Stack.ContentType('blog_post').Query();
1649+
Query
1650+
.above('taxonomies.one', 'term_one')
1651+
.toJSON()
1652+
.find()
1653+
.then(entries => {
1654+
assert.ok(entries[0].length, 'Entries present in the resultset');
1655+
assert.end();
1656+
}, err => {
1657+
console.error("error :", err);
1658+
assert.fail("Taxonomies Endpoint: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)");
1659+
assert.end();
1660+
})
1661+
})

0 commit comments

Comments
 (0)