Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add more tests

  • Loading branch information...
commit 5d3709d53dd167d2715277ab7646e5e24e8c5e3d 1 parent f7e46fd
@Baggz authored
Showing with 84 additions and 0 deletions.
  1. +84 −0 tests/tests.js
View
84 tests/tests.js
@@ -897,4 +897,88 @@ suite('JSON', function() {
}));
});
+});
+
+/**
+ * More ambitious notations
+ * --------------------
+ */
+suite('More Ambitious Notations', function() {
+
+ var testObject = {
+ user: {
+ profile: {
+ name: {
+ firstName: {
+ "my First name": {
+ name: 'František'
+ }
+ }
+ }
+ }
+ }
+ };
+
+ test("using the ‘user.profile.name.firstName['my First name'].name’ notation", function() {
+ var result = pinch(testObject, "user.profile.name.firstName['my First name'].name", 'Test');
+ expect(result.user.profile.name.firstName['my First name'].name).to.be.eql('Test');
+ });
+
+ test("using the ‘['user'].profile.name.firstName['my First name'].name’ notation", function() {
+ var result = pinch(testObject, "['user'].profile.name.firstName['my First name'].name", 'Test');
+ expect(result.user.profile.name.firstName['my First name'].name).to.be.eql('Test');
+ });
+
+ test("using the ‘['user']['profile'].name.firstName['my First name'].name’ notation", function() {
+ var result = pinch(testObject, "['user']['profile'].name.firstName['my First name'].name", 'Test');
+ expect(result.user.profile.name.firstName['my First name'].name).to.be.eql('Test');
+ });
+
+ test("using the ‘['user']['profile']['name'].firstName['my First name'].name’ notation", function() {
+ var result = pinch(testObject, "['user']['profile']['name'].firstName['my First name'].name", 'Test');
+ expect(result.user.profile.name.firstName['my First name'].name).to.be.eql('Test');
+ });
+
+ test("using the ‘['user']['profile']['name']['firstName']['my First name'].name’ notation", function() {
+ var result = pinch(testObject, "['user']['profile']['name']['firstName']['my First name'].name", 'Test');
+ expect(result.user.profile.name.firstName['my First name'].name).to.be.eql('Test');
+ });
+
+ test("using the ‘['user']['profile']['name']['firstName']['my First name']['name']’ notation", function() {
+ var result = pinch(testObject, "['user']['profile']['name']['firstName']['my First name']['name']", 'Test');
+ expect(result.user.profile.name.firstName['my First name'].name).to.be.eql('Test');
+ });
+
+ // --------------------
+
+ test('using the ‘user.profile.name.firstName["my First name"].name’ notation', function() {
+ var result = pinch(testObject, 'user.profile.name.firstName["my First name"].name', "Test");
+ expect(result.user.profile.name.firstName["my First name"].name).to.be.eql('Test');
+ });
+
+ test('using the ‘["user"].profile.name.firstName["my First name"].name’ notation', function() {
+ var result = pinch(testObject, '["user"].profile.name.firstName["my First name"].name', "Test");
+ expect(result.user.profile.name.firstName["my First name"].name).to.be.eql('Test');
+ });
+
+ test('using the ‘["user"]["profile"].name.firstName["my First name"].name’ notation', function() {
+ var result = pinch(testObject, '["user"]["profile"].name.firstName["my First name"].name', "Test");
+ expect(result.user.profile.name.firstName["my First name"].name).to.be.eql('Test');
+ });
+
+ test('using the ‘["user"]["profile"]["name"].firstName["my First name"].name’ notation', function() {
+ var result = pinch(testObject, '["user"]["profile"]["name"].firstName["my First name"].name', "Test");
+ expect(result.user.profile.name.firstName["my First name"].name).to.be.eql('Test');
+ });
+
+ test('using the ‘["user"]["profile"]["name"]["firstName"]["my First name"].name’ notation', function() {
+ var result = pinch(testObject, '["user"]["profile"]["name"]["firstName"]["my First name"].name', "Test");
+ expect(result.user.profile.name.firstName["my First name"].name).to.be.eql('Test');
+ });
+
+ test('using the ‘["user"]["profile"]["name"]["firstName"]["my First name"]["name"]’ notation', function() {
+ var result = pinch(testObject, '["user"]["profile"]["name"]["firstName"]["my First name"]["name"]', "Test");
+ expect(result.user.profile.name.firstName["my First name"].name).to.be.eql('Test');
+ });
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.