Skip to content

Commit

Permalink
[FABN-599] Unit tests for Constants
Browse files Browse the repository at this point in the history
- Constants tests using mocha at 100% coverage
- Fixed licensing errors in Constants

Change-Id: I08763988a723c6d826415735e353a1976c9cf0a4
Signed-off-by: Liam Grace <liamgrace.896@gmail.com>
  • Loading branch information
liam-grace committed Sep 12, 2018
1 parent 2855a85 commit eee0b27
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 5 deletions.
17 changes: 12 additions & 5 deletions fabric-client/lib/Constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/*
Copyright 2016, 2018 IBM All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

Expand Down
65 changes: 65 additions & 0 deletions fabric-client/test/Contants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const Constants = require('../lib/Constants');

describe('Constants', () => {
it('should set the correct LSCC constant', () => {
Constants.LSCC.should.equal('lscc');
});

it('should set the correct QSCC constant', () => {
Constants.QSCC.should.equal('qscc');
});

it('should set the correct CSCC constant', () => {
Constants.CSCC.should.equal('cscc');
});

it('should set the correct SYSTEM_CHANNEL_NAME constant', () => {
Constants.SYSTEM_CHANNEL_NAME.should.equal('testchainid');
});

it('should set the correct NetworkConfig.ENDORSING_PEER_ROLE contant', () => {
Constants.NetworkConfig.ENDORSING_PEER_ROLE.should.equal('endorsingPeer');
});

it('should set the correct NetworkConfig.CHAINCODE_QUERY_ROLE constant', () => {
Constants.NetworkConfig.CHAINCODE_QUERY_ROLE.should.equal('chaincodeQuery');
});

it('should set the correct NetworkConfig.LEDGER_QUERY_ROLE constant', () => {
Constants.NetworkConfig.LEDGER_QUERY_ROLE.should.equal('ledgerQuery');
});

it('should set the correct NetworkConfig.EVENT_SOURCE_ROLE constant', () => {
Constants.NetworkConfig.EVENT_SOURCE_ROLE.should.equal('eventSource');
});

it('should set the correct NetworkConfig.DISCOVERY_ROLE constant', () => {
Constants.NetworkConfig.DISCOVERY_ROLE.should.equal('discover');
});

it('should set the correct NetworkConfig.ALL_ROLES constant', () => {
Constants.NetworkConfig.ALL_ROLES.should.equal('all');
});

it('should set the correct NetworkConfig.ROLES constant', () => {
Constants.NetworkConfig.ROLES.should.deep.equal([
'endorsingPeer', 'chaincodeQuery', 'ledgerQuery', 'eventSource', 'discover', 'all'
]);
});
});

0 comments on commit eee0b27

Please sign in to comment.