|
| 1 | +/** |
| 2 | + * Copyright (c) 2002-2015 "Neo Technology," |
| 3 | + * Network Engine for Objects in Lund AB [http://neotechnology.com] |
| 4 | + * |
| 5 | + * This file is part of Neo4j. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +var neo4j = require("../../lib/v1"); |
| 21 | +var StatementType = require("../../lib/v1/result-summary").statementType; |
| 22 | + |
| 23 | +fdescribe('transaction', function() { |
| 24 | + |
| 25 | + var driver, session; |
| 26 | + |
| 27 | + beforeEach(function(done) { |
| 28 | + driver = neo4j.driver("bolt://localhost"); |
| 29 | + session = driver.session(); |
| 30 | + |
| 31 | + session.run("MATCH (n) DETACH DELETE n").then(done); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should handle simple transaction', function(done) { |
| 35 | + // When |
| 36 | + var tx = session.beginTransaction(); |
| 37 | + tx.run("CREATE (:TXNode1)"); |
| 38 | + tx.run("CREATE (:TXNode2)"); |
| 39 | + tx.commit() |
| 40 | + .then(function() { |
| 41 | + session.run("MATCH (t1:TXNode1), (t2:TXNode2) RETURN count(t1), count(t2)").then(function(records) { |
| 42 | + |
| 43 | + expect( records.length ).toBe( 1 ); |
| 44 | + expect( records[0]['count(t1)'].toInt() ) |
| 45 | + .toBe( 1 ); |
| 46 | + expect( records[0]['count(t2)'].toInt() ) |
| 47 | + .toBe( 1 ); |
| 48 | + done(); |
| 49 | + }); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | +}); |
0 commit comments